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

(module) mjs vs (main) cjs #142

Closed
nelisbijl opened this issue Mar 14, 2022 · 2 comments
Closed

(module) mjs vs (main) cjs #142

nelisbijl opened this issue Mar 14, 2022 · 2 comments

Comments

@nelisbijl
Copy link

I created a library with vue-demi.
vue-demi as dependency in package.json
vue-demi in externals in vue.config.js
using vue-cli-service build --target lib
This includes the following in it's output:

module.exports = require("vue-demi");

Now when I use this library in a Vue2 application using @vue/composition-api, I end up with 2 versions from @vue/composition-api: vue-composition-api.mjs and vue-composition-api.common.cjs which causes the usual conflicts.
My guess is, that the application uses the mjs version, whereas the library uses the cjs version due to webpack's require statement.

What am I doing wrong? What can be done to prevent this?

@wobsoriano
Copy link
Contributor

Would be nice to see your package.json.exports key. It usually looks like this:

"exports": {
    "require": "./dist/index.cjs",
    "import": "./dist/index.mjs"
},
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",

@DanilTod
Copy link

nelisbijl
Look at #113 (comment), should fix your problem

@sxzz sxzz closed this as completed Sep 4, 2022
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

4 participants