Description
Description
module-sync
condition is a condition enabled by Node.js when require(esm)
is enabled. It is supported by the config loader (#18650), but not by the SSR module loader.
Suggested solution
Add module-sync
condition to default ssr.resolve.externalCondition
.
Alternative
Leave it as-is and tell users to configure it when needed.
Additional context
- related: Resolution allows extension-less import which is not aligned with package
exports
field #18300 - we don't support
export { foo as 'module.exports' }
(module: support 'module.exports' interop export name in require(esm) nodejs/node#54563) in the config loader but we should support that as well - The reason of not proposing adding
module-sync
tossr.resolve.conditions
is to follow Node.js's recommendation.
Quoting from the Node 22.10.0 release post:For bundlers/tools: they should avoid implementing this stop-gap condition. Most existing bundlers implement the de-facto bundler standard
module
exports condition, and that should be enough to support users who want to bundle ESM from CJS consumers. Users who want both bundlers and Node.js to recognize the ESM exports can use bothmodule
/module-sync
conditions during the transition period, and can dropmodule-sync
+module
when they no longer need to support older versions of Node.js. If tools do want to support this condition, it's recommended to make the resolution rules in the graph pointed by this condition match the Node.js native ESM rules to avoid divergence.
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.