Skip to content

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

@xie219205

Description

@xie219205

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'),
}),
],
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions