Skip to content

feat: Extend diagnostics hook to async and require - #49

Merged
isaacs merged 1 commit into
mainfrom
feat/extend-diagnostics-hook
Jul 14, 2026
Merged

feat: Extend diagnostics hook to async and require#49
isaacs merged 1 commit into
mainfrom
feat/extend-diagnostics-hook

Conversation

@timfish

@timfish timfish commented Jul 14, 2026

Copy link
Copy Markdown
Member

The async Module.register hooks run on a separate loader thread, so the diagnostics hook set on the main thread was never called on that path.

  • createDiagnosticsPort() returns a MessagePort to pass to Module.register via data.diagnosticsPort and transferList; the loader thread posts transform diagnostics back over it to the hook set with setDiagnosticsHook.
  • The Module.prototype._compile patch now emits diagnostics too, since it is what transforms CommonJS on this path.

ESM diagnostics on the async path arrive asynchronously and the port does not keep the process alive.

@isaacs isaacs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is the correct way to do it. 👍

@isaacs
isaacs merged commit 8351727 into main Jul 14, 2026
8 checks passed
@isaacs
isaacs deleted the feat/extend-diagnostics-hook branch July 14, 2026 23:30
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