diff --git a/package.json b/package.json index 014e7b2e1..5cff3189f 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "acorn": "^6.0.2", "acorn-jsx": "^5.0.0", "ast-types": "^0.11.6", - "buble": "^0.19.4", + "buble": "0.19.4", "classnames": "^2.2.6", "clean-webpack-plugin": "^0.1.19", "clipboard-copy": "^2.0.1", @@ -83,9 +83,9 @@ "rewrite-imports": "1.2.0", "to-ast": "^1.0.0", "type-detect": "^4.0.8", - "uglifyjs-webpack-plugin": "1.2.7", "unist-util-visit": "^1.4.0", "walkes": "^0.2.1", + "terser-webpack-plugin": "^1.1.0", "webpack-dev-server": "^2.11.2", "webpack-merge": "^4.1.4" }, diff --git a/src/scripts/__tests__/make-webpack-config.spec.js b/src/scripts/__tests__/make-webpack-config.spec.js index e46f69b20..c347fea58 100644 --- a/src/scripts/__tests__/make-webpack-config.spec.js +++ b/src/scripts/__tests__/make-webpack-config.spec.js @@ -34,7 +34,7 @@ it('should return a development config', () => { }); expect(config).not.toHaveProperty('optimization'); } else { - expect(plugins).not.toContain('UglifyJsPlugin'); + expect(plugins).not.toContain('TerserPlugin'); } }); @@ -59,9 +59,9 @@ it('should return a production config', () => { expect(config).toMatchObject({ mode: env, }); - expect(getClasses(config.optimization.minimizer, 'UglifyJsPlugin')).toHaveLength(1); + expect(getClasses(config.optimization.minimizer, 'TerserPlugin')).toHaveLength(1); } else { - expect(plugins).toContain('UglifyJsPlugin'); + expect(plugins).toContain('TerserPlugin'); } }); diff --git a/src/scripts/make-webpack-config.js b/src/scripts/make-webpack-config.js index aa39a11d6..59e7d252e 100644 --- a/src/scripts/make-webpack-config.js +++ b/src/scripts/make-webpack-config.js @@ -1,6 +1,6 @@ const path = require('path'); const webpack = require('webpack'); -const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); +const TerserPlugin = require('terser-webpack-plugin'); const MiniHtmlWebpackPlugin = require('mini-html-webpack-plugin'); const MiniHtmlWebpackTemplate = require('@vxna/mini-html-webpack-template'); const CleanWebpackPlugin = require('clean-webpack-plugin'); @@ -85,17 +85,17 @@ module.exports = function(config, env) { ], }); - const uglifier = new UglifyJSPlugin({ + const uglifier = new TerserPlugin({ parallel: true, cache: true, - uglifyOptions: { + terserOptions: { ie8: false, ecma: 5, compress: { keep_fnames: true, warnings: false, /* - * Disable reduce_funcs to keep UglifyJS from inlining + * Disable reduce_funcs to keep Terser from inlining * Preact's VNode. If enabled, the 'new VNode()' is replaced * with a anonymous 'function(){}', which is problematic for * preact-compat, since it extends the VNode prototype to diff --git a/src/scripts/utils/__tests__/mergeWebpackConfig.spec.js b/src/scripts/utils/__tests__/mergeWebpackConfig.spec.js index 95fc69534..3ec00575f 100644 --- a/src/scripts/utils/__tests__/mergeWebpackConfig.spec.js +++ b/src/scripts/utils/__tests__/mergeWebpackConfig.spec.js @@ -1,6 +1,6 @@ import mergeWebpackConfig from '../mergeWebpackConfig'; -class UglifyJsPlugin {} +class TerserPlugin {} class MyPlugin {} class MiniHtmlWebpackPlugin {} @@ -27,8 +27,8 @@ it('should ignore certain sections', () => { }); it('should ignore certain Webpack plugins', () => { - const baseInstance = new UglifyJsPlugin(); - const userInstance = new UglifyJsPlugin(); + const baseInstance = new TerserPlugin(); + const userInstance = new TerserPlugin(); const result = mergeWebpackConfig( { plugins: [baseInstance], @@ -39,7 +39,7 @@ it('should ignore certain Webpack plugins', () => { ); expect(result.plugins).toHaveLength(2); expect(result.plugins[0]).toBe(baseInstance); - expect(result.plugins[0].constructor.name).toBe('UglifyJsPlugin'); + expect(result.plugins[0].constructor.name).toBe('TerserPlugin'); expect(result.plugins[1].constructor.name).toBe('MyPlugin'); }); diff --git a/src/scripts/utils/mergeWebpackConfig.js b/src/scripts/utils/mergeWebpackConfig.js index 46fcfb8bd..13a7ad00b 100644 --- a/src/scripts/utils/mergeWebpackConfig.js +++ b/src/scripts/utils/mergeWebpackConfig.js @@ -16,7 +16,7 @@ const IGNORE_PLUGINS = [ 'HtmlWebpackPlugin', 'OccurrenceOrderPlugin', 'DedupePlugin', - 'UglifyJsPlugin', + 'TerserPlugin', 'HotModuleReplacementPlugin', ];