Open kingyue737 opened 2 years ago
Let's keep this open. We'll work on this once ECharts and ZRender fix this on their side.
Let's keep this open. We'll work on this once ECharts and ZRender fix this on their side.
I bumped issue in apache/echarts
repo, may be you need to leave the comment about it in https://github.com/apache/echarts/issues/16709
For anybody interested to fix it in their project with echarts 5.4.0 and vue-echarts 6.2.3:
postinstall
script ("postinstall": "patch-package",
)patches
in the root folder of your projectpatches
foldernpm install
/ yarn install
echarts+5.4.0.patch
:
diff --git a/node_modules/echarts/package.json b/node_modules/echarts/package.json
index 9ee583c..cd4513e 100644
--- a/node_modules/echarts/package.json
+++ b/node_modules/echarts/package.json
@@ -1,5 +1,6 @@
{
"name": "echarts",
+ "type": "module",
"version": "5.4.0",
"description": "Apache ECharts is a powerful, interactive charting and data visualization library for browser",
"license": "Apache-2.0",
vue-echarts+6.2.3.patch
:
diff --git a/node_modules/vue-echarts/package.json b/node_modules/vue-echarts/package.json
index a571fde..174515f 100644
--- a/node_modules/vue-echarts/package.json
+++ b/node_modules/vue-echarts/package.json
@@ -1,5 +1,13 @@
{
"name": "vue-echarts",
+ "type": "module",
+ "exports": {
+ ".": {
+ "require": "./dist/index.cjs.js",
+ "import": "./dist/index.esm.js",
+ "types": "./dist/index.d.ts"
+ }
+ },
"version": "6.2.3",
"description": "Vue.js component for Apache ECharts.",
"author": "GU Yiling <justice360@gmail.com>",
For anybody interested to fix it in their project with echarts 5.4.0 and vue-echarts 6.2.3:
- add patch-package and setup the
postinstall
script ("postinstall": "patch-package",
)- create a folder named
patches
in the root folder of your project- add the following files to the
patches
folder- run
npm install
/yarn install
echarts+5.4.0.patch
:diff --git a/node_modules/echarts/package.json b/node_modules/echarts/package.json index 9ee583c..cd4513e 100644 --- a/node_modules/echarts/package.json +++ b/node_modules/echarts/package.json @@ -1,5 +1,6 @@ { "name": "echarts", + "type": "module", "version": "5.4.0", "description": "Apache ECharts is a powerful, interactive charting and data visualization library for browser", "license": "Apache-2.0",
vue-echarts+6.2.3.patch
:diff --git a/node_modules/vue-echarts/package.json b/node_modules/vue-echarts/package.json index a571fde..174515f 100644 --- a/node_modules/vue-echarts/package.json +++ b/node_modules/vue-echarts/package.json @@ -1,5 +1,13 @@ { "name": "vue-echarts", + "type": "module", + "exports": { + ".": { + "require": "./dist/index.cjs.js", + "import": "./dist/index.esm.js", + "types": "./dist/index.d.ts" + } + }, "version": "6.2.3", "description": "Vue.js component for Apache ECharts.", "author": "GU Yiling <justice360@gmail.com>",
Yes, I also walked this path, but it's becomming impossible when I convert my project into npm package. Now I'm trying to find a way to prevent installation of vue-echarts in project root node_modules, but in my package root instead
Hi!
If using with Vite, Node Vite dev server and Echarts v5.4.2 I get the following error using this code:
import { use } from 'echarts/core'
import { CanvasRenderer } from 'echarts/renderers'
import { PieChart } from 'echarts/charts'
import { TitleComponent, TooltipComponent, LegendComponent } from 'echarts/components'
import VChart, { THEME_KEY } from 'vue-echarts'
use([CanvasRenderer, PieChart, TitleComponent, TooltipComponent, LegendComponent])
Error
node_modules/echarts/core.js:20
export * from './lib/export/core.js';
^^^^^^
SyntaxError: Unexpected token 'export'
at internalCompileFunction (node:internal/vm:73:18)
...
Meet this issue again in Nuxt with SSR enabled. https://nuxt.com/docs/guide/concepts/esm#what-kinds-of-problems-can-there-be
Need conditional-exports in a Node.js ESM context
Let's keep this open. We'll work on this once ECharts and ZRender fix this on their side.
Both zrender
v5.5 and echarts
v5.5 have been released 🎉
The dependency resize-detector
also needs to be fixed
Let's keep this open. We'll work on this once ECharts and ZRender fix this on their side.
Both
zrender
v5.5 andecharts
v5.5 have been released 🎉The dependency
resize-detector
also needs to be fixed
Just in time for me. Relevant links: apache/echarts#19513 and ecomfe/zrender#1051.
@Justineo Any timeline on this? Would be really appreciated. Resorting to patching atm.
Currently blocked by https://github.com/apache/echarts/issues/19663 (we have TS issues at https://github.com/ecomfe/vue-echarts/issues/766). We'll resolve this one after https://github.com/apache/echarts/issues/19663 is resolved.
Confirmation
How are you introducing Vue-ECharts into your project?
ES Module imports
Versions
Details
I'm using
vue-echarts
withvitest
. But vitest throw the following error:According to the comment of vitest member https://github.com/vitest-dev/vitest/issues/1452#issuecomment-1150750725 , this is because
vue-charts
points to cjs entry that usesrequire
which is not intercepted byvitest
.See also his comment in another issue of vue-echarts here: https://github.com/ecomfe/vue-echarts/issues/601#issuecomment-1150797371
Reproduction
stackblitz.com/edit/vitest-dev-vitest-fhmvl9