Skip to content

feat: use module.registerHooks for amaro/strip and amaro/transform - #497

Merged
marco-ippolito merged 1 commit into
nodejs:mainfrom
GeoffreyBooth:geoffreybooth-register-hooks
Oct 26, 2026
Merged

marco-ippolito merged 1 commit into
nodejs:mainfrom
GeoffreyBooth:geoffreybooth-register-hooks

Conversation

@GeoffreyBooth

@GeoffreyBooth GeoffreyBooth commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Switches amaro/strip and amaro/transform to synchronous module.registerHooks() when available, so Node.js can eventually remove module.register(). Benefits: no loader thread, and hooks also apply to require() of TypeScript.

On Node.js versions without registerHooks (<22.15 / 23.0–23.4), the entry points fall back to module.register() with the async hook, so this is not breaking and engines stays >=22.

  • Loaders export loadSync (registerHooks) and load (register fallback), sharing the strip/transform logic.
  • New test/register-hooks.test.js; registerHooks-only tests are skipped on older Node.
  • README updated.

Tested: full suite on Node 26; loader tests on 22.13.1, 22.15.0, 23.2.0, 24.1.0 and others via n.

cc @marco-ippolito @joyeecheung @mcollina

@GeoffreyBooth
GeoffreyBooth force-pushed the geoffreybooth-register-hooks branch from 47c38ff to ca8cfd0 Compare October 26, 2026 04:00
@GeoffreyBooth GeoffreyBooth changed the title feat!: use module.registerHooks for amaro/strip and amaro/transform feat: use module.registerHooks for amaro/strip and amaro/transform Oct 26, 2026
Use synchronous module.registerHooks() when available, so the loaders
also apply to require() of TypeScript and avoid the loader thread.
Fall back to module.register() on Node.js versions without it.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@GeoffreyBooth
GeoffreyBooth force-pushed the geoffreybooth-register-hooks branch from ca8cfd0 to 9f3187b Compare October 26, 2026 04:16
@marco-ippolito
marco-ippolito merged commit b6bf196 into nodejs:main Oct 26, 2026
12 checks passed
@GeoffreyBooth
GeoffreyBooth deleted the geoffreybooth-register-hooks branch October 26, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants