feat(node)!: replace async module.register with sync module.registerHooks#28
Merged
Conversation
this decision is subject to change
…ooks Merge sync.mts implementation into hooks.mts and update register.mts to use module.registerHooks() directly. Remove the separate ./sync export as the main entry point is now sync-only. BREAKING CHANGE: async hooks via module.register() are replaced with sync hooks via module.registerHooks(). Requires Node.js >= 22.18.0.
…odule.registerHooks`
module.registerHooks() was backported to Node.js 22.15.0 LTS, so 22.18.0 was unnecessarily restrictive. Also fix the version range for --experimental-strip-types in the README.
…ming convention Rename SyncNextResolveFn/SyncNextLoadFn to NextResolveFnSync/NextLoadFnSync to align with the Node.js suffix convention (ResolveHookSync, LoadHookSync).
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
module.register()(async, off-thread) withmodule.registerHooks()(sync, in-thread) in@power-assert/node, following its deprecation as DEP0205@power-assert/transpiler>=22.15.0Motivation
The async/off-thread hook model of
module.register()had fundamental architectural issues that the Node.js team deemed unresolvable: deadlocks, lostconsole.log()output, inability to covercreateRequire(), and inter-thread communication overhead. It was runtime-deprecated in v26.0.0 and is slated for removal in v27.Changes
@power-assert/transpilertranspileSync(),transpileWithInlineSourceMapSync(),transpileWithSeparatedSourceMapSync(), andfindIncomingSourceMapSync()to support synchronous hooks@power-assert/nodehooks.mtsfrom async functions to sync typed function expressions (ResolveHookSync/LoadHookSync)register.mtsto usemodule.registerHooks()with direct function references instead of indirect specifier-basedmodule.register()engines.nodeto>=22.15.0Docs
Breaking Changes
module.register()are replaced with sync hooks viamodule.registerHooks()>=22.15.0