Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add module-sync condition to default ssr.resolve.externalCondition #19201

Open
4 tasks done
sapphi-red opened this issue Jan 14, 2025 · 0 comments
Open
4 tasks done

Add module-sync condition to default ssr.resolve.externalCondition #19201

sapphi-red opened this issue Jan 14, 2025 · 0 comments
Labels
enhancement New feature or request feat: ssr p3-significant High priority enhancement (priority)

Comments

@sapphi-red
Copy link
Member

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 to ssr.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 both module/module-sync conditions during the transition period, and can drop module-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

@sapphi-red sapphi-red added enhancement New feature or request feat: ssr p3-significant High priority enhancement (priority) labels Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feat: ssr p3-significant High priority enhancement (priority)
Projects
None yet
Development

No branches or pull requests

1 participant