Open joyeecheung opened 2 months ago
(Slightly unrelated) Maybe we should add a new tracker
label to the repo?
@nodejs/loaders
I just wanted to note it here, but it would be super super awesome if (once stable) this were backported to Node 20/22 or even Node 18 if still in support. I'd love to be able to propose a change to switch TypeScript to ESM (given I have it working without breaking CJS consumers), but the time horizon of Node 22 being the oldest supported version is pretty daunting.
It also seems like there is a hacky way using multiple entrypoints that could allow for TS to grab Node's builtins conditionally without #52599/#52762, though none of that is possible without require(ESM)
, of course.
Even without TypeScript's use case, I think the feature itself is a really important one for the ecosystem. Backporting would really make ESM changeovers a lot less painful.
IIRC from some Twitter threads - there is a plan to backport this once the feature stabilizes.
Before it's unflagged
__esModule
to required ESM on our end (https://github.com/nodejs/node/pull/52166), or transpilers update themselves to check the result returned byrequire()
:Before it is promoted to be stable:
Nice-to-haves: