gdborton / webpack-parallel-uglify-plugin

A faster uglifyjs plugin.
466 stars 34 forks source link

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

Open xie219205 opened 2 years ago

xie219205 commented 2 years ago

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