vue-demi
vue-demi copied to clipboard
(module) mjs vs (main) cjs
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?
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",
nelisbijl Look at https://github.com/vueuse/vue-demi/issues/113#issuecomment-953783034, should fix your problem