在学习自定义构建工具的时候遇到了麻烦,官网写的自定义有两种办法,跟着教程走了半天不幸的是两种方法一直报错,都未能成功。所以想把错误记录下来,请大家帮忙解决一下,百度后几种解决方法尝试无果。好在网站提供自定义组件的图形化自动生成模式,可以在页面生成自己想要的echart模版。
在安装的时候这个模块npm i rollup-plugin-uglify@3.0.0 需要安装这个版本的否则使用会出问题
第一种错误信息
//当我们运行这条命令的时候
node node_modules/echarts/build/build.js --min -i echarts.custom.js -o lib/echarts.custom.min.js
Bundles /Users/xinwang/Desktop/myProject/echarts.custom.js => /Users/xinwang/Desktop/myProject/lib/echarts.custom.min.js ...
Unknown input option: legacy. Allowed options: acorn, acornInjectPlugins, cache, chunkGroupingSize, context, experimentalCacheExpiry, experimentalOptimizeChunks, experimentalTopLevelAwait, external, inlineDynamicImports, input, manualChunks, moduleContext, onwarn, perf, plugins, preserveModules, preserveSymlinks, shimMissingExports, treeshake, watch
Error: Could not resolve entry (/Users/xinwang/Desktop/myProject/echarts.custom.js)
undefined
第二种自定义方式错误信息
//当我们运行这条命令的时候
./node_modules/.bin/rollup -c
!) You have passed an unrecognized option
Unknown input option: name. Allowed options: acorn, acornInjectPlugins, cache, chunkGroupingSize, context, experimentalCacheExpiry, experimentalOptimizeChunks, experimentalTopLevelAwait, external, inlineDynamicImports, input, manualChunks, moduleContext, onwarn, perf, plugins, preserveModules, preserveSymlinks, shimMissingExports, treeshake, watch
./line.js → lib/line.min.js...
(!) Missing exports
https://rollupjs.org/guide/en#error-name-is-not-exported-by-module-
line.js
init is not exported by node_modules/echarts/lib/echarts.js
9: // 基于准备好的dom,初始化 echarts 实例并绘制图表。
10: //console.log(echarts)
11: echarts.init(document.getElementById('main')).setOption({
^什么鬼说这里没有这个方法
12: title: {text: 'Line Chart'},
13: tooltip: {},
(!) uglify plugin: The transformBundle hook used by plugin uglify is deprecated. The renderChunk hook should be used instead.
created lib/line.min.js in 801ms