You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Reduce reliance on Node's non-public internal module interfaces (internal/modules/esm/*)
#7710
While looking into how the harness resolves modules, I found the boot path reaches into Node's non-public internal modules instead of public APIs. Built output of dsh-app-boot (lib/index.js):
/* v8 ignore start -- the supported Node 22/24/26 matrix validates each available Internal interface */
Why I think this is worth revisiting
internal/* carries no stability guarantee, and that comment shows the cost is already being paid: each supported Node major (22/24/26) has to be validated separately against whatever internal shape that release happens to ship. Because this sits on the boot path, a moved or renamed internal interface fails host preparation outright, hard-failing the whole app rather than degrading.
Node now exposes public APIs that cover much of the same surface:
module.registerHooks() β synchronous resolve/load hooks (available since Node 22.15, present in Node 26);
module.register() β the async variant.
Acknowledged trade-off
I understand why the internal route was chosen: it keeps resolution byte-for-byte consistent with Node's own semantics, and shares the cascaded loader instance instead of reimplementing a resolver. I am not proposing a rewrite β the ask is narrower:
shrink the per-Node-major version-adaptation surface wherever a public API can substitute; and
let the boot path degrade gracefully instead of hard-failing when an internal interface it wants is unavailable.
A secondary (not primary) benefit is that it would make non-Node runtimes conceivable at all.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Context
While looking into how the harness resolves modules, I found the boot path reaches into Node's non-public internal modules instead of public APIs. Built output of
dsh-app-boot(lib/index.js):The source acknowledges the coupling explicitly:
/* v8 ignore start -- the supported Node 22/24/26 matrix validates each available Internal interface */Why I think this is worth revisiting
internal/*carries no stability guarantee, and that comment shows the cost is already being paid: each supported Node major (22/24/26) has to be validated separately against whatever internal shape that release happens to ship. Because this sits on the boot path, a moved or renamed internal interface fails host preparation outright, hard-failing the whole app rather than degrading.Node now exposes public APIs that cover much of the same surface:
module.registerHooks()β synchronous resolve/load hooks (available since Node 22.15, present in Node 26);module.register()β the async variant.Acknowledged trade-off
I understand why the internal route was chosen: it keeps resolution byte-for-byte consistent with Node's own semantics, and shares the cascaded loader instance instead of reimplementing a resolver. I am not proposing a rewrite β the ask is narrower:
A secondary (not primary) benefit is that it would make non-Node runtimes conceivable at all.
Environment
All reactions