Skip to content

fix(@angular/build): use module.registerHooks() for in-memory ESM loader - #34359

Merged
alan-agius4 merged 1 commit into
angular:mainfrom
alan-agius4:fix-register-hooks-dep0205
Oct 15, 2026
Merged

alan-agius4 merged 1 commit into
angular:mainfrom
alan-agius4:fix-register-hooks-dep0205

Conversation

@alan-agius4

Copy link
Copy Markdown
Collaborator

Node.js 26 runtime-deprecates module.register() (DEP0205) in favor of synchronous module.registerHooks().

Update the server-rendering in-memory ESM loader hooks to make load synchronous using readFileSync and register the hooks directly via registerHooks({ resolve, load }).

Closes #34358

@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Oct 15, 2026
@alan-agius4
alan-agius4 requested a review from clydin October 15, 2026 12:27

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the ESM in-memory loader hooks to run synchronously by replacing readFile with readFileSync and updating the load function and its associated tests. It also attempts to change the hook registration mechanism in register-hooks.ts to use registerHooks. However, a critical issue was identified: registerHooks is not a valid Node.js API, and because ESM loaders run in a separate thread, local function references cannot be passed directly. The registration must be reverted to use the standard register() API with the loader file path.

Node.js 26 runtime-deprecates `module.register()` (`DEP0205`) in favor of
synchronous `module.registerHooks()`.

Update the server-rendering in-memory ESM loader hooks to make `load`
synchronous using `readFileSync` and register the hooks directly via
`registerHooks({ resolve, load })`.

Closes angular#34358
@alan-agius4
alan-agius4 force-pushed the fix-register-hooks-dep0205 branch from 7b28748 to 943f21e Compare October 15, 2026 12:30
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Oct 15, 2026
@alan-agius4
alan-agius4 merged commit b640b32 into angular:main Oct 15, 2026
40 checks passed
@alan-agius4
alan-agius4 deleted the fix-register-hooks-dep0205 branch October 15, 2026 14:22
@alan-agius4

Copy link
Copy Markdown
Collaborator Author

This PR was merged into the repository. The changes were merged into the following branches:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/build target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

module.register() in the prerender loader prints DEP0205 on Node 26

2 participants