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

[RFC] Drop CommonJS entry point #4899

Closed
susnux opened this issue Nov 30, 2023 · 1 comment · Fixed by #5610
Closed

[RFC] Drop CommonJS entry point #4899

susnux opened this issue Nov 30, 2023 · 1 comment · Fixed by #5610
Labels
discussion Need advices, opinions or ideas on this topic
Milestone

Comments

@susnux
Copy link
Contributor

susnux commented Nov 30, 2023

We currently provide CommonJS and ESM entry points.
While ESM is able to import CommonJS packages, the opposite does only work with dynamic import() and not with require().

This causes issues as some of our dependencies are pure ESM dependencies, meaning our CJS output is theoretically invalid, because it contains require('pure-esm-module').
This causes issues with tools like jest, as the code is not valid.

(Notice that for app users this is not a problem, if they use Vite it will load the ESM entry and if they use webpack it will transpile this library and all dependencies to UMD)

But I see no benefit of providing both types, as CommonJS users will still have to transpile this library because of the dependencies.


My reasons for going pure ESM:

  • Less error prone distribution (we had problems with one of both types being invalid with both webpack and vite)
  • ESM is the standard (and hopefully someday being it also in the Node.js universe)
  • Simplify tooling & build process
  • Smaller distribution size
  • Needs to be transpiled anyway so should be no change for users.

I am happy to hear your thoughts, especially if you know reasons for keeping both 😃

@susnux susnux added the discussion Need advices, opinions or ideas on this topic label Nov 30, 2023
@susnux susnux added this to the 9.0.0 next Vue 3 milestone Nov 30, 2023
@raimund-schluessler
Copy link
Contributor

What is needed to implement this? Just drop main and all the export.*.require fields in package.json?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Need advices, opinions or ideas on this topic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants