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: importing from esm in node #814

Merged
merged 1 commit into from Sep 21, 2021
Merged

fix: importing from esm in node #814

merged 1 commit into from Sep 21, 2021

Conversation

chearon
Copy link
Contributor

@chearon chearon commented Sep 21, 2021

Right now you can't import {watch} from "@vue/composition-api" in nodejs from a .mjs file. If you try that, you'll get:

file:///Users/caleb/Code/temp/x.mjs:1
import {ref} from "@vue/composition-api";
        ^^^
SyntaxError: Named export 'ref' not found. The requested module '@vue/composition-api' is a CommonJS module, which may not support all module.exports as named exports.

I think since there's no "type" in package.json, the default module type for any .js is CJS. The files in the red and the green appear to be identical so I think this is low-risk and the right way to do it. As I understand it Webpack will parse anything, it doesn't really have a concept of module type, and not sure about other bundlers.

@antfu antfu merged commit 8c61b07 into vuejs:main Sep 21, 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.

None yet

2 participants