-
Notifications
You must be signed in to change notification settings - Fork 44
feat: Optionally only wrap modules hooked in --import
#146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
7335da6
feat: Only instrument hooked modules
timfish bc8eb03
Fix test and lint
timfish b001494
Update types
timfish 612abcf
also import path to ensure it can still be hooked after
timfish a92146a
Update readme
timfish bf1cde8
Merge branch 'main' into feat/only-instrument-hooked
timfish ab39976
typos
timfish 766bc2b
Merge branch 'feat/only-instrument-hooked' of https://github.com/timf…
timfish e9c7c41
line breaks
timfish b784138
Ensure all messages to loader are acknowledged
timfish d82c8ae
debug failing CI
timfish 708ed61
more CI
timfish d41b017
Use a timer to stop exit code 13
timfish 35fdfe0
update types docs
timfish 323bfc2
Fix types
timfish 6c4384b
Merge remote-tracking branch 'upstream/main' into feat/only-instrumen…
timfish b70a48f
Add `registerOptions`
timfish 3a510c4
Correct jsdoc in types
timfish 7299d2d
Add jsdoc to createAddHookMessageChannel
timfish 2d3fc58
Mark this feature as experimental
timfish 0654e75
Merge remote-tracking branch 'upstream/main' into feat/only-instrumen…
timfish e0ebcb9
Fix up PR merges
timfish File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { strictEqual } from 'assert' | ||
| import { sep } from 'path' | ||
| import { Hook } from '../../index.js' | ||
|
|
||
| const hooked = [] | ||
|
|
||
| Hook((_, name) => { | ||
| hooked.push(name) | ||
| }) | ||
|
|
||
| strictEqual(hooked.length, 1) | ||
| strictEqual(hooked[0], 'path') | ||
| strictEqual(sep, '@') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { register } from 'module' | ||
| import { Hook, createAddHookMessageChannel } from '../../index.js' | ||
| // We've imported path here to ensure that the hook is still applied later. | ||
| import * as path from 'path' | ||
|
|
||
| const addHookMessagePort = createAddHookMessageChannel() | ||
|
|
||
| register('../../hook.mjs', import.meta.url, { data: { addHookMessagePort }, transferList: [addHookMessagePort] }) | ||
|
|
||
| Hook(['path'], (exports) => { | ||
| exports.sep = '@' | ||
| }) | ||
|
|
||
| console.assert(path.sep !== '@') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { spawnSync } from 'child_process' | ||
|
|
||
| const out = spawnSync(process.execPath, | ||
| ['--import', './test/fixtures/import.mjs', './test/fixtures/import-after.mjs'], | ||
| { stdio: 'inherit', env: {} } | ||
| ) | ||
| process.exit(out.status) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.