docs: record that a shimmed package is invisible to async ESM hooks

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019bYKAjrx5D2WSbEFCg16gb
This commit is contained in:
Ruben Fiszel
2026-09-01 11:57:09 +00:00
co-authored by Claude Opus 5
parent 3509302be3
commit d767b1c3d0
@@ -89,7 +89,9 @@ function cjsShim(specifier) {
".cjs";
mkdirSync(cjsShimDir, { recursive: true });
// The local binding is load-bearing: bun collapses a bare `module.exports = require(x)` back
// into a passthrough external import, which is the shape that breaks node.
// into a passthrough external import, which is the shape that breaks node. A shimmed package
// is reached by `require`, so node's async ESM hooks (`register()`) no longer see it; its
// sync `registerHooks()` and `--require` interception still do.
writeFileSync(
shim,
"const mod = require(" + JSON.stringify(specifier) + ");\nmodule.exports = mod;\n"