Skip to content

Commit 2300f9e

Browse files
authored
Switch from uglifyjs to terser (#5026)
Uglify is no longer maintained and has bugs not present in Terser (its successor)
1 parent e6ba967 commit 2300f9e

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

packages/react-dev-utils/printBuildError.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ module.exports = function printBuildError(err) {
1313
const message = err != null && err.message;
1414
const stack = err != null && err.stack;
1515

16-
// Add more helpful message for UglifyJs error
16+
// Add more helpful message for Terser error
1717
if (
1818
stack &&
1919
typeof message === 'string' &&
20-
message.indexOf('from UglifyJs') !== -1
20+
message.indexOf('from Terser') !== -1
2121
) {
2222
try {
2323
const matched = /(.+)\[(.+):(.+),(.+)\]\[.+\]/.exec(stack);

packages/react-error-overlay/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"rimraf": "^2.6.2",
6161
"settle-promise": "1.0.0",
6262
"source-map": "0.5.6",
63-
"uglifyjs-webpack-plugin": "1.2.5",
63+
"terser-webpack-plugin": "1.1.0",
6464
"webpack": "^4.8.1"
6565
},
6666
"jest": {

packages/react-error-overlay/webpack.config.iframe.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
const path = require('path');
1010
const webpack = require('webpack');
11-
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
11+
const TerserPlugin = require('terser-webpack-plugin');
1212

1313
module.exports = {
1414
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
@@ -49,8 +49,8 @@ module.exports = {
4949
minimizer: [
5050
// This code is embedded as a string, so it would never be optimized
5151
// elsewhere.
52-
new UglifyJsPlugin({
53-
uglifyOptions: {
52+
new TerserPlugin({
53+
terserOptions: {
5454
compress: {
5555
warnings: false,
5656
comparisons: false,

packages/react-scripts/config/webpack.config.prod.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const autoprefixer = require('autoprefixer');
1212
const path = require('path');
1313
const webpack = require('webpack');
1414
const HtmlWebpackPlugin = require('html-webpack-plugin');
15-
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
15+
const TerserPlugin = require('terser-webpack-plugin');
1616
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
1717
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
1818
const ManifestPlugin = require('webpack-manifest-plugin');
@@ -115,10 +115,10 @@ module.exports = {
115115
},
116116
optimization: {
117117
minimizer: [
118-
new UglifyJsPlugin({
119-
uglifyOptions: {
118+
new TerserPlugin({
119+
terserOptions: {
120120
parse: {
121-
// we want uglify-js to parse ecma 8 code. However, we don't want it
121+
// we want terser to parse ecma 8 code. However, we don't want it
122122
// to apply any minfication steps that turns valid ecma 5 code
123123
// into invalid ecma 5 code. This is why the 'compress' and 'output'
124124
// sections only apply transformations that are ecma 5 safe

packages/react-scripts/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@
6464
"style-loader": "0.21.0",
6565
"svgr": "1.9.2",
6666
"sw-precache-webpack-plugin": "0.11.5",
67+
"terser-webpack-plugin": "1.1.0",
6768
"thread-loader": "1.2.0",
68-
"uglifyjs-webpack-plugin": "1.2.5",
6969
"url-loader": "1.0.1",
7070
"webpack": "4.19.0",
7171
"webpack-dev-server": "3.1.7",

0 commit comments

Comments
 (0)