-
-
Notifications
You must be signed in to change notification settings - Fork 139
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
ERR_MODULE_NOT_FOUND : echarts\core only during SSG Build #201
Comments
Created a reproduction here: |
@ElmoArmy 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):
node_modules/echarts
{
"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
node_modules/resize-detector
|
@ElmoArmy we need also modify this another dependency: node_modules/zrender
|
@ElmoArmy the chart component can also be included without the dynamic import, the have you tried my repro? |
Just got back to my office. Pulling it now and I'll let you know how it goes. |
@ElmoArmy pushed changes, also included |
included |
Your repo works like a charm after making those changes. Thanks for your help in figuring this out. In order to fix this for others, would suggest I just start issues in the echarts, vue-echarts, resize-detector, zrender packages? |
@ElmoArmy here a good explanation about |
Great resource. Thanks again for your help. |
@ElmoArmy update both issues since you're suggesting to only support You need to exclude type module on both issues, and include the required module renaming:
|
Oh I completely misunderstood that until you just explained this. I will update those issues. Thank you for further explaining this. |
@ElmoArmy FYI: just read again the second point here https://v3.nuxtjs.org/concepts/esm#library-author-guide, I change all the dependencies on my repro and so I don't need to change the esm modules with js extension; maybe it can also be done using the corresponding esm module on the import on my repo instead changing the |
@ElmoArmy one last thing, the repo should also check the
EDIT: |
So I just attempted to implement this in the PR for the Seem right to you?
In regards to this comment, how would I evaluate whether or not this library ( or any library for that matter) should use sideEffects: False or specificy sideffects to make further bundling more efficient? |
@ElmoArmy
|
@ElmoArmy you should start fixing deps is reverse order, starting with zrender and resize-detector, then echarts and finally vue-echarts |
Ok, I'll look for those. I think I see an example of at least one in the vue-charts library (an imported css file) that should be included. I also did some reading around the issue and I think I understand this optimization a bit more clearly. Thanks.
Yea, this a great tip. Thanks. One last thing:Let's say I wanted to update a repo that depends on these libs with a workaround while changes make it upstream. Some options I'd consider would be :
Any opinions on a preferable solution for a consumer that wants to sidestep mjs vs cjs issues in a less manual way than modifying the deps on install? |
@ElmoArmy please send me an email here userquin@gmail.com, and if you have Discord account send me also your nick. |
Sent. |
no, check the address |
is here something we can do to resolve this issue before |
@heynext create a patch script and apply it on |
thx. the changes work! i write a script to do the changes import fs from 'fs'
import path from 'path'
const patchPkg = (name, data) => {
const pkgPath = path.resolve('node_modules', name, 'package.json')
const pkg = JSON.parse(fs.readFileSync(pkgPath))
const patchedPkg = {
...pkg,
...data,
}
fs.writeFileSync(pkgPath, JSON.stringify(patchedPkg, null, 2))
}
patchPkg('echarts', {
type: 'module',
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',
},
},
})
patchPkg('zrender', {
type: 'module',
})
patchPkg('resize-detector', {
type: 'module',
exports: {
'.': {
require: './dist/index.js',
import: './esm/index.js',
},
},
})
patchPkg('vue-echarts', {
type: 'module',
exports: {
'.': {
require: './dist/index.cjs.js',
import: './dist/index.esm.js',
types: './dist/index.d.ts',
},
},
}) |
@heynext protect the |
Thanks @userquin, @heynext. Is there any non-public news about the offending packages? patchPkg('echarts', {
type: 'module',
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',
},
// here
'./features': {
require: './features.js',
import: './features.js',
types: './features.d.ts',
},
},
}) |
vite.config.json |
I'm having an issue integrating apache's echarts and vue-echarts specifically when building in SSG mode. Everything works under vite build and vite (dev mode) but ssg build fails. I'm pretty sure this is an issue with the echarts package format, but I don't know how to get this to work in my SSG build. Any hints or ideas would be appreciated!!
https://github.com/ecomfe/vue-echarts
https://github.com/apache/echarts
vite-ssg build
If I try to add '.js' to the end of all the echarts imports the error changes to :
other attempts at fixing this issue
<client-only>
I have an SFC that looks like this and is being imported on a page:
The text was updated successfully, but these errors were encountered: