Skip to content

Commit

Permalink
chore: replace uglifyjs with terser for minifying prod builds (#1061)
Browse files Browse the repository at this point in the history
Replaces the minifier we're using on prod builds from `uglify-js` to `terser`.

Terser is a more updated replacement for UglifyJS. Webpack 4 switched to using it as the default minifier in Nov 2018 (webpack/webpack#8392). The reasons we'd want to switch:

* Unblocks future updates to typescript output target; uglify only supports up to ES5 javascript, Terser supports more recent javascript as input
* Closer to the "normal" webpack happy path
* As of recently, [more widely used (with webpack)](https://www.npmtrends.com/uglifyjs-webpack-plugin-vs-terser-webpack-plugin)

It is essentially a drop in replacement; we expect no customer-visible changes as a result of this update.
  • Loading branch information
dbjorge committed Aug 13, 2019
1 parent a376992 commit de1cf60
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -97,14 +97,14 @@
"serve-static": "^1.13.2",
"source-map-loader": "^0.2.4",
"spectron": "^8.0.0",
"terser-webpack-plugin": "^1.4.1",
"ts-jest": "^24.0.2",
"ts-loader": "^6.0.4",
"tslint": "^5.18.0",
"tslint-microsoft-contrib": "6.2.0",
"typed-scss-modules": "^0.0.11",
"typemoq": "^2.1.0",
"typescript": "^2.9.2",
"uglifyjs-webpack-plugin": "^2.2.0",
"webpack": "^4.39.1",
"webpack-cli": "^3.3.6"
},
Expand Down
6 changes: 3 additions & 3 deletions webpack.config.js
Expand Up @@ -3,7 +3,7 @@
const path = require('path');
const webpack = require('webpack');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const TerserWebpackPlugin = require('terser-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

Expand Down Expand Up @@ -153,9 +153,9 @@ const prodConfig = {
optimization: {
splitChunks: false,
minimizer: [
new UglifyJsPlugin({
new TerserWebpackPlugin({
sourceMap: false,
uglifyOptions: {
terserOptions: {
compress: false,
mangle: false,
output: {
Expand Down
17 changes: 1 addition & 16 deletions yarn.lock
Expand Up @@ -8464,29 +8464,14 @@ ua-parser-js@^0.7.20:
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.20.tgz#7527178b82f6a62a0f243d1f94fd30e3e3c21098"
integrity sha512-8OaIKfzL5cpx8eCMAhhvTlft8GYF8b2eQr6JkCyVdrgjcytyOmPCXrqXFcUnhonRpLlh5yxEZVohm6mzaowUOw==

uglify-js@^3.1.4, uglify-js@^3.6.0:
uglify-js@^3.1.4:
version "3.6.0"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.6.0.tgz#704681345c53a8b2079fb6cec294b05ead242ff5"
integrity sha512-W+jrUHJr3DXKhrsS7NUVxn3zqMOFn0hL/Ei6v0anCIMoKC93TjcflTagwIHLW7SfMFfiQuktQyFVCFHGUE0+yg==
dependencies:
commander "~2.20.0"
source-map "~0.6.1"

uglifyjs-webpack-plugin@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-2.2.0.tgz#e75bc80e7f1937f725954c9b4c5a1e967ea9d0d7"
integrity sha512-mHSkufBmBuJ+KHQhv5H0MXijtsoA1lynJt1lXOaotja8/I0pR4L9oGaPIZw+bQBOFittXZg9OC1sXSGO9D9ZYg==
dependencies:
cacache "^12.0.2"
find-cache-dir "^2.1.0"
is-wsl "^1.1.0"
schema-utils "^1.0.0"
serialize-javascript "^1.7.0"
source-map "^0.6.1"
uglify-js "^3.6.0"
webpack-sources "^1.4.0"
worker-farm "^1.7.0"

unc-path-regex@^0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/unc-path-regex/-/unc-path-regex-0.1.2.tgz#e73dd3d7b0d7c5ed86fbac6b0ae7d8c6a69d50fa"
Expand Down

0 comments on commit de1cf60

Please sign in to comment.