Intent to ship browser packages as ES Modules exclusively
- Dominant language
- No language data
- Stars
- 1
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
`npm` modules never end up in the browser without a compilation/bundling step¹ and since all bundlers now support ES Modules (natively or via `esm` package) it makes no sense to keep shipping Common JS modules, which have [compatibility issues](https://github.com/webpack/webpack/issues/4742) with ES Modules and [different expectations](https://github.com/sindresorhus/meta/issues/6) for multiple exports.
## Browser + node packages
**Only ship CommonJS,** since they're supported everywhere and most bundlers also have a compatibility layer to enable `import`ing them, which correctly selects the "default" CommonJS export.
## Browser-only packages
**Only ship ES Module,** since the only reason to have CommonJS modules at the moment is to support older Node versions.
This will change as Node finalizes ES Module support and is widespread enough to completely and finally drop CommonJS.
---
¹ If you want to use one of my `npm`-only modules directly in the browser, I provide a [`packd`](https://github.com/Rich-Harris/packd) link that makes a bundle for you, example: https://github.com/fregante/webext-options-sync/commit/37d606a5363617858ada4828bf83cc36b48f735c
Contributor guide
No contributing guide indexed for this repository
Research direction
No repository files, tests, or entry points are named. Start by reviewing the browser-only versus browser-and-Node package distinction and the linked compatibility discussions; done would require an agreed package-shipping policy.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- tooling, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100