Open
Description
Before it's unflagged
- Figure out default export interop with transpilers, either adding
__esModule
to required ESM on our end (module: add __esModule to require()'d ESM #52166), or transpilers update themselves to check the result returned byrequire()
: - conditional exports for module, regardless of whether it's loaded by
require
orimport
. Something likemodule
which is recognized by Webpack and Rollup would be good (maybe this doesn't need to block unflagging, but should be done before stablization) module: implement the "module-sync" exports condition #54648 - Move experimental warning to where
require()
is actually handling a ESM
Before it is promoted to be stable:
- Implement detection module: support ESM detection in the CJS loader #52047
- Some marker to customize the default exports returned by require(esm) module: support 'module.exports' interop export name in require(esm) #54563
- Support module customization hooks doc: add synchronous hooks proposal loaders#198
Nice-to-haves:
- Add API for dumping or inspecting the consolidated CJS and EJS module graph #52180
- Provide some mechanism to conditionally and synchronously import modules (or just builtins) from ESM #52599 (fixed in process: add process.getBuiltinModule(id) #52762)
- Better documentation on how to publish packages in a post-require-esm era/migration guide: https://github.com/nodejs/package-examples
Bug fixes & changes:
- module: disallow CJS <-> ESM edges in a cycle from require(esm) #52264
- module: fix submodules loaded by require() and import() #52487
- module: support ESM detection in the CJS loader #52047
- module: cache synchronous module jobs before linking #52868
- module: add __esModule to require()'d ESM #52166
- module: remove bogus assertion in CJS entrypoint handling with --import #54592
- module: implement the "module-sync" exports condition #54648
- module: check --experimental-require-module separately from detection #55250
- module: include module information in require(esm) warning #55397
- module: trim off internal stack frames for require(esm) warnings #55496
- module: allow ESM that failed to be required to be re-imported #55502
- module: fix error thrown from require(esm) hitting TLA repeatedly #55520
- module: do not warn when require(esm) comes from node_modules #55960
- module: mark evaluation rejection in require(esm) as handled #56122
- module: only emit require(esm) warning under --trace-require-module #56194
Related features that interoperate with require(esm) and need to be considered when being backported together:
For v22.x backport (see a summary of regression analysis in #55217 (comment))
- process: add process.features.require_module #55241
- module: use kNodeModulesRE to detect node_modules #55243
- src: implement IsInsideNodeModules() in C++ #55286
- [v22.x] backport unflagging of --experimental-require-module and related fixes/refactorings #55217
For v20.x backport: TBD