Closed s-sasaki-0529 closed 2 years ago
Hmm it should be working with webpack too. I will look at your repo.
In this codesandbox there is no problem https://codesandbox.io/s/vue-chart-3-vue-2-mw54f?file=/src/App.vue
And if you're in webpack, it's not normal to have an error in the mjs
file
ERROR in ./node_modules/vue-chart-3/dist/index.mjs
. This file is for ESM bundlers only, webpack must use index.js
commonjs build.
Can confirm, you have missing webpack configuration. I strongely advise you to use vue-cli
for all your Vue 2 project as it ships with the correct configuration and avoid those errors
I strongely advise you to use vue-cli for all your Vue 2 project as it ships with the correct configuration and avoid those errors
Thanks for the advice. However, we can't use vue-cli in our product because we use webpack directly.
Can confirm, you have missing webpack configuration.
I found out that my repository uses webpack v5 and vue-cli uses webpack v4.
This package uses the exports field in pakcage.json, but webpack will not use it until v5. (refs) So, only when webpack v5 try to resolve import vue-chart-3
it refers to the mjs
file.
Therefore this issue is correct: Not work with webpack 5
.
Probably, this package is not intended to be used with webpack 5, so I will try to solve this problem with webpack configuration. Thank you.
Hmm yes it seems webpack 5 does not handle ESM like Vite.js or Nuxt 3. Sorry for the confusion, i will look at it and see if it doesn't break build for Webpack 4 or Vite :)
I'm just curious in the reason to use vanilla Vue directly because vue-cli lets you customize the webpack config as well
Try v2.1.2
Thank you very much for your reply. I'm looking forward to v2.1.2!
I'm just curious in the reason to use vanilla Vue directly because vue-cli lets you customize the webpack config as well
Well... It's an old project, so I don't know, but I think it's because it's very customisable and we can use the latest tools. (eg. webpack 5)
Describe the bug
Thanks for the nice package to use Chart.js 3 with Vue 3! I would like to use this to simplify my migration from Vue 2 to 3.
but when using
vue-chart-3@legacy
with webpack, I get the following error.To Reproduce
Please see the following repository (sorry, I couldn't reproduce this in codesandbox) https://github.com/s-sasaki-0529/reproduce-vue-chart-3-issue
Version of
vue-chart-3
v2.1.1
Version of Vue
My solution
It seems that esm is supported for vite, but the standard webpack configuration does not solve this problem.
The following settings may resolve, but I would be grateful if you could specify the extension in components.ts. https://webpack.js.org/configuration/module/#resolvefullyspecified