Skip to content
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

echarts error:main.js:1 Uncaught Error: axisPointer CartesianAxisPointer exists #71

Open
xie219205 opened this issue Dec 12, 2021 · 0 comments

Comments

@xie219205
Copy link

When I use webpack-parallel-uglify-plugin and echarts,I got a error:

main.js:1 Uncaught Error: axisPointer CartesianAxisPointer exists
at Function.a.registerAxisPointerClass (vendor.js:1)
at Object.install (vendor.js:1)
at t (vendor.js:1)
at Object.install (vendor.js:1)
at t (vendor.js:1)
at Module../node_modules/echarts/index.js (vendor.js:1)
at w (main.js:1)
at e (main.js:1)
at Module../src/index.ts (main.js:1)
at w (main.js:1)

After comparison and investigation,I found webpack-parallel-uglify-plugin cause the error.

versions:
"echarts": "^5.2.2",
"webpack-parallel-uglify-plugin": "^2.0.0",

webpack.config.js:
const HtmlWebpackPlugin = require('html-webpack-plugin');
const BundleAnalyzerPlugin =
require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const path = require('path');
const HappyPack = require('happypack');
const ParallelUglifyPlugin = require('webpack-parallel-uglify-plugin');

module.exports = {
entry: path.resolve(__dirname, 'src', 'index.ts'),
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
chunkFilename: '[name].[hash:4].js',
},
resolve: {
extensions: ['.ts', '.js'],
},
optimization: {
// 1. 这个配置必须
minimize: false,
splitChunks: {
cacheGroups: {
default: {
name: 'common',
chunks: 'initial',
minChunks: 2,
priority: -20,
},
vendors: {
test: /[\/]node_modules[\/]/,
name: 'vendor',
chunks: 'initial',
priority: -10,
},
},
},
},
devtool: 'cheap-source-map',
module: {
rules: [
{
test: /.css$/,
use: ['happypack/loader?id=css'],
// use: ['style-loader', 'css-loader'],
},
{
test: /.(ts|js)$/,
use: ['happypack/loader?id=babel'],
// loader: 'babel-loader',
exclude: [path.join(__dirname, 'node_modules')],
// options: {
// presets: ['@babel/preset-env', '@babel/typescript'],
// },
},
],
},
devServer: {
port: 'auto',
client: {
reconnect: 5,
progress: true,
},
hot: true,
static: path.resolve(__dirname, 'dist/index.html'),
},
plugins: [
new BundleAnalyzerPlugin(),
new ParallelUglifyPlugin({
uglifyJS: {
// output: {
// beautify: false,
// comments: false,
// },
// warnings: false,
// compress: {
// drop_console: true,
// collapse_vars: true,
// reduce_vars: true,
// },
},
}),
new HappyPack({
id: 'babel',
use: [
{
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/typescript'],
},
},
],
}),
new HappyPack({
id: 'css',
loaders: ['style-loader', 'css-loader'],
}),
new HtmlWebpackPlugin({
title: 'TypeScript Learner',
filename: path.resolve(__dirname, 'dist', 'index.html'),
template: path.resolve(__dirname, 'public', 'index.html'),
}),
],
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant