Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] implement module.registerHooks() to run synchronous module customization hooks in thread #55698

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

joyeecheung
Copy link
Member

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 and load are implemented to reach parity with module.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.

Previously in the CommonJS loader, --inspect-brk is implemented
checking whether the module points to the result of re-resolving
process.argv[1] to determine whether the module is the entry point.
This is unnecessarily complex, especially now that we store that
information in the module as kIsMainSymbol. This patch updates
it to simply check that symbol property instead.
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/loaders
  • @nodejs/startup

@nodejs-github-bot nodejs-github-bot added esm Issues and PRs related to the ECMAScript Modules implementation. module Issues and PRs related to the module subsystem. needs-ci PRs that need a full CI run. labels Nov 2, 2024
@RedYetiDev RedYetiDev added semver-minor PRs that contain new features and should be released in the next minor version. wip Issues and PRs that are still a work in progress. labels Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
esm Issues and PRs related to the ECMAScript Modules implementation. module Issues and PRs related to the module subsystem. needs-ci PRs that need a full CI run. semver-minor PRs that contain new features and should be released in the next minor version. wip Issues and PRs that are still a work in progress.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants