module.registerHooks() tracking issue
Open
Nobody has claimed this yet.
loaders
module
- Dominant language
- JavaScript
- Stars
- 122k
- Forks
- 37.3k
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 283
Description
- Support
node:builtin?param=val& figure out how to make search params work with CJS cache- Some clues can be found in https://github.com/nodejs/node/pull/62920 (which smooths it for internal test mocking)
-
Symbol.disposeintegration (requested in https://github.com/nodejs/node/pull/55698#discussion_r1855211481) - Initial proposal: https://github.com/nodejs/node/issues/52219
- Loaders design proposal: https://github.com/nodejs/loaders/pull/198
- Initial implementation: https://github.com/nodejs/node/pull/55698
- Make the internal resolution and loading paths synchronous, to reduce the chance of races https://github.com/nodejs/node/pull/60380
so thatwe can't really polyfillmodule.register()can be an helper built on top ofmodule.registerHooks(), and internally we only have one set of hooking points to take care ofmodule.registerwith it if we want to keep the internals to ourselves, oh well - Handle with the nullish sources of CommonJS caused by
module.register()quirk during interop: https://github.com/nodejs/node/pull/59929- For ESM, there's currently no way for Node.js to hook into the evaluation of child modules, will need to discuss with V8 about it (issue). Allowing mutation of the exports would require a spec change so out of scope for
module.registerHooks()or Node.js in general
- For ESM, there's currently no way for Node.js to hook into the evaluation of child modules, will need to discuss with V8 about it (issue). Allowing mutation of the exports would require a spec change so out of scope for
- Reordering of the documentation when
module.registerHooks()is battle tested enough and should be preferred overmodule.registerto avoid various caveats https://github.com/nodejs/node/issues/56241 - Support of unknown extensions (learned about it when I was initially proposing https://github.com/nodejs/node/issues/52219): this is already fully possible with the resolve hook?
Moved to https://github.com/nodejs/node/issues/62720
- Implement link hook for ESM, as proposed in https://github.com/nodejs/loaders/pull/198 to make use cases like import-in-the-middle less hacky https://github.com/nodejs/node/issues/62720
startGraphhook proposed in https://github.com/nodejs/loaders/pull/205- Implement evaluation hook for at least CJS to help use cases like require-in-the-middle, which was supposed to be based on https://github.com/nodejs/loaders/pull/198 but we had some discussions over the collaboration summit/NodeConf EU about changing the hook to be "wrapping around evaluation", not "after evaluation": WIP
Nice to have:
- Advocating it to popular npm packages doing CJS monkey-patching to reduce the overall dependency of CJS loader internals in the ecosystem
- Create a polyfill of
module.register()built on top ofmodule.registerHooks(): WIP in https://github.com/joyeecheung/module-register-ponyfill
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the successor issue https://github.com/nodejs/node/issues/62720 and the linked Node.js loaders proposals, especially the link and startGraph hooks. This tracking issue has moved elsewhere and lists unresolved design work, so its completion criteria are not defined here.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 15/100