these are the changes I made, you can see it here https://github.com/userquin/vitesse-apache-echarts using vitesse template (the changes on the dependencies should be done manually, not included on the repo):
package.json
: add"type": "module"
vite.config.ts
: changed the import forVueI18n
and included some entries onoptimizedDeps/include
optiontsconfig.json
: changedmodule
toESNext
insteades2016
src/components/ChartComponent.vue
usingvue-echarts/dist/index.esm.js
insteadvue-echarts
(maybe we need to also change thepackage.json
ofvue-echarts
)pnpm install
: once dependencies installed you must modify the following dependencies (we can also apply something similar toecharts
...)
node_modules/echarts
package.json
: add"type": "module"
, add alsoexports
entry beforemain
entry, the file should be like this:
{
"name": "echarts",
"version": "5.3.0",
"description": "Apache ECharts is a powerful, interactive charting and data visualization library for browser",
"license": "Apache-2.0",
"type": "module",
"keywords": [
"echarts",
"data-visualization",
"charts",
"charting-library",
"visualization",
"apache",
"data-viz",
"canvas",
"svg"
],
"exports": {
".": {
"require": "./dist/echarts.js",
"import": "./dist/echarts.esm.js",
"types": "./index.d.ts"
},
"./core": {
"require": "./core.js",
"import": "./core.js",
"types": "./core.d.ts"
},
"./renderers": {
"require": "./renderers.js",
"import": "./renderers.js",
"types": "./renderers.d.ts"
},
"./charts": {
"require": "./charts.js",
"import": "./charts.js",
"types": "./charts.d.ts"
},
"./components": {
"require": "./components.js",
"import": "./components.js",
"types": "./components.d.ts"
}
},
"main": "dist/echarts.js",
node_modules/vue-echarts
dist/index.esm.js
: replaceimport { addListener, removeListener } from 'resize-detector';
withimport { addListener, removeListener } from 'resize-detector/esm/index.js';
package.json
add"type": "module"
, add alsoexports
entry beforemain
entry, the file should be like this:
"type": "module",
"scripts": {
"serve": "vue-cli-service serve",
"build": "npm run docs && rimraf dist && rollup -c rollup.config.js && cp src/index.vue2.d.ts dist",
"lint": "vue-cli-service lint",
"build:demo": "vue-cli-service build",
"docs": "node -r esm ./scripts/docs.js",
"postinstall": "node ./scripts/postinstall.js",
"prepare": "npm run build"
},
"exports": {
".": {
"require": "./dist/index.cjs.js",
"import": "./dist/index.esm.js",
"types": "./dist/index.d.ts"
}
},
},
node_modules/resize-detector
package.json
add"type": "module"
node_modules/zrender
package.json
add"type": "module"