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

[Feature]: Provode .mjs artifact #99

Closed
chenjiahan opened this issue Oct 18, 2023 · 3 comments · Fixed by #2361
Closed

[Feature]: Provode .mjs artifact #99

chenjiahan opened this issue Oct 18, 2023 · 3 comments · Fixed by #2361
Milestone

Comments

@chenjiahan
Copy link
Member

What problem does this feature solve?

Provode .mjs artifact for ESM imports.

What does the proposed API look like?

Both CommonJS and ESModule should be supported.

@chenjiahan
Copy link
Member Author

@10Derozan cc

@fi3ework
Copy link
Member

Quotes from 1.0 roadmap

Before the release of v1.0, we need to finish the ESM support for all packages

Given Rsbuild is a quite new project, we have more choices on this topic based on Vite's valuable experience.

  1. Only ship ESM dist to NPM. This might be too bold as we have given up users who can't migrate to ESM project.
  2. Only ship async API from rebuild and @rsbuild/shared in CJS version. API is for upper-level framework, so this won't break anything as the ecosystem will grow up after 1.0, also this could push the upper-level to embrace ESM. When we migrate to ESM only in the future, we won't blocked from dropping sync API support.

Also, there's a risk of loading duplicated modules from ESM and CJS from the same source module distributed in CJS and ESM. A thin ESM wrapper to support ESM would be a more secure method.

@fi3ework fi3ework added this to the 1.0.0 milestone Feb 28, 2024
@chenjiahan
Copy link
Member Author

chenjiahan commented Feb 28, 2024

It would be very nice if we could use the ESM wrapper to keep compatible with CJS users.

Add some information for this:

  • Rspack does not yet have full ESM loader support ([Feature]: Support native ESM loader rspack#5735)
  • Our packages have exported some constants (such as version), which may not be converted to async API.
  • All Modern.js packages are still use the CJS API..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants