[WIP] implement module.registerHooks() to run synchronous module customization hooks in thread #55698
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.
This is not yet ready for review, as I haven't written enough tests - though there are already some tests to check whether a mock for pirates and a mock for a mini TypeScript transpiler works and they pass locally. This is opened as a draft for demonstration at the collaboration summit next week.
This implements part of the proposal in nodejs/loaders#198 - for the motivations, see #52219 (although I guess the amount of "this caveat of asynchronous hooks does not apply to the synchronous hooks" added in the documentation kind of already proves the point..).
For now only
resolve
andload
are implemented to reach parity withmodule.register()
. I left the exports hook to https://github.com/joyeecheung/node/tree/export-hooks which will be a follow-up when we decide the timing at which the post-load hook for CJS should run.The first commit comes from #55679. The commit
module: use synchronous hooks for preparsing in import(cjs)
isn't strictly necessary and could split into a follow-up instead.