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

fix: don't expose incorrect ESM entry in exports #70

Merged
merged 2 commits into from Jul 5, 2021

Conversation

sodatea
Copy link
Contributor

@sodatea sodatea commented Jun 30, 2021

Fixes #66.

Node.js sees .js files as CJS modules if there's no type: "module" in package.json. So index.esm.js can't be imported from ES modules.

However, CJS modules can be imported from ES modules, named exports are also supported if it is statically analyzable.
So simply removing the import field should be just fine.

The module field is only used by bundlers, so keeping .js extension is harmless.


A better fix would be using a proper .mjs extension for the ESM build. But I haven't investigated #63, so I chose the safer approach.

@sibbng
Copy link
Member

sibbng commented Jun 30, 2021

I would suggest naming that import field to browser. So we can keep using it on browser environment. Like jspm.io which is doesn't transform files on the fly like Skypack.

package.json Show resolved Hide resolved
@sibbng sibbng requested a review from antfu June 30, 2021 19:20
@antfu antfu merged commit f0be853 into vueuse:master Jul 5, 2021
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

Successfully merging this pull request may close these issues.

Exporting ESM module as CJS
3 participants