From 373b43b5e0b541c16fd66c028d43145f6c133f62 Mon Sep 17 00:00:00 2001 From: Pavel Prichodko Date: Fri, 3 Aug 2018 13:50:24 +0200 Subject: [PATCH] Switch from uglify-es to terser --- packages/react-dev-utils/printBuildError.js | 4 ++-- packages/react-error-overlay/package.json | 2 +- packages/react-error-overlay/webpack.config.iframe.js | 6 +++--- packages/react-scripts/config/webpack.config.prod.js | 8 ++++---- packages/react-scripts/package.json | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/react-dev-utils/printBuildError.js b/packages/react-dev-utils/printBuildError.js index 0fe7aa9a552..1e70b4e64f4 100644 --- a/packages/react-dev-utils/printBuildError.js +++ b/packages/react-dev-utils/printBuildError.js @@ -13,11 +13,11 @@ module.exports = function printBuildError(err) { const message = err != null && err.message; const stack = err != null && err.stack; - // Add more helpful message for UglifyJs error + // Add more helpful message for Terser error if ( stack && typeof message === 'string' && - message.indexOf('from UglifyJs') !== -1 + message.indexOf('from Terser') !== -1 ) { try { const matched = /(.+)\[(.+):(.+),(.+)\]\[.+\]/.exec(stack); diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index 6e7e1f3e885..2b777b028f0 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -60,7 +60,7 @@ "rimraf": "^2.6.2", "settle-promise": "1.0.0", "source-map": "0.5.6", - "uglifyjs-webpack-plugin": "1.2.5", + "terser-webpack-plugin": "^1.0.0", "webpack": "^4.8.1" }, "jest": { diff --git a/packages/react-error-overlay/webpack.config.iframe.js b/packages/react-error-overlay/webpack.config.iframe.js index 3a806f362db..67157bad440 100644 --- a/packages/react-error-overlay/webpack.config.iframe.js +++ b/packages/react-error-overlay/webpack.config.iframe.js @@ -8,7 +8,7 @@ const path = require('path'); const webpack = require('webpack'); -const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); +const TerserPlugin = require('terser-webpack-plugin'); module.exports = { mode: process.env.NODE_ENV === 'production' ? 'production' : 'development', @@ -49,8 +49,8 @@ module.exports = { minimizer: [ // This code is embedded as a string, so it would never be optimized // elsewhere. - new UglifyJsPlugin({ - uglifyOptions: { + new TerserPlugin({ + terserOptions: { compress: { warnings: false, comparisons: false, diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 86869748c66..6f9aeba80e1 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -12,7 +12,7 @@ const autoprefixer = require('autoprefixer'); const path = require('path'); const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin'); -const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); +const TerserPlugin = require('terser-webpack-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin'); const ManifestPlugin = require('webpack-manifest-plugin'); @@ -116,10 +116,10 @@ module.exports = { }, optimization: { minimizer: [ - new UglifyJsPlugin({ - uglifyOptions: { + new TerserPlugin({ + terserOptions: { parse: { - // we want uglify-js to parse ecma 8 code. However, we don't want it + // we want terser to parse ecma 8 code. However, we don't want it // to apply any minfication steps that turns valid ecma 5 code // into invalid ecma 5 code. This is why the 'compress' and 'output' // sections only apply transformations that are ecma 5 safe diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index cc590619417..927bbb4d369 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -65,7 +65,7 @@ "svgr": "1.9.2", "sw-precache-webpack-plugin": "0.11.5", "thread-loader": "1.1.5", - "uglifyjs-webpack-plugin": "1.2.5", + "terser-webpack-plugin": "^1.0.0", "url-loader": "1.0.1", "webpack": "4.8.3", "webpack-dev-server": "3.1.7",