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

Suggest remove main and module if have exports #24

Open
bluwy opened this issue Jan 16, 2023 · 0 comments
Open

Suggest remove main and module if have exports #24

bluwy opened this issue Jan 16, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@bluwy
Copy link
Owner

bluwy commented Jan 16, 2023

The exports field supersedes other mainFields, if the tooling supports the exports field.

exports is supported since:

  • Node.js v12.7 (Release: 2019-07-23) (history)
    • Around the same time when ESM support is stabilized (history)
    • Earliest ESM support is v8.5, but adoption could be considered low as it was experimental until v12.20
  • Webpack 5 (Release: 2020-10-10)
    • Webpack 4 does not support exports, which is what the majority still uses.
  • @rollupjs/plugin-node-resolve v11.1 (Release: 2021-01-15)
  • Parcel 2.9.0 (Release: 2023-05-26) - Use package.json#exports map parcel-bundler/parcel#4155
  • Other recent tooling should support this by default.

exports is still not supported by:


Given the state of support, perhaps we have to wait a bit longer. Because many packages will have both main/module and exports, and suggesting this would be a huge breaking change without much benefit.

I think there's now enough support to start providing this suggestion. There's still the concern that it's totally fine to keep using the main fields just in case, but I think this is a good nudge towards a single way to export things, and will help simplify library publishing in the future.

This suggestion is initially brought up in #21.

@bluwy bluwy added the enhancement New feature or request label Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant