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

Intent to ship browser packages as ES Modules exclusively #1

Open
fregante opened this issue Dec 7, 2019 · 0 comments
Open

Intent to ship browser packages as ES Modules exclusively #1

fregante opened this issue Dec 7, 2019 · 0 comments

Comments

@fregante
Copy link
Owner

fregante commented Dec 7, 2019

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 with ES Modules and different expectations for multiple exports.

Browser + node packages

Only ship CommonJS, since they're supported everywhere and most bundlers also have a compatibility layer to enable importing 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 link that makes a bundle for you, example: fregante/webext-options-sync@37d606a

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

No branches or pull requests

1 participant