Skip to content

Commit

Permalink
refactor(bundles): Migrate from uglify to terser (#3813)
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherthielen authored Jul 21, 2020
1 parent e4991a5 commit 4f9a607
Show file tree
Hide file tree
Showing 3 changed files with 430 additions and 417 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@
"lodash": "^4.17.15",
"prettier": "^2.0.5",
"pretty-quick": "^2.0.1",
"rollup": "^1.27.14",
"rollup": "^2.22.1",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-sourcemaps": "^0.5.0",
"rollup-plugin-uglify": "^6.0.4",
"rollup-plugin-sourcemaps": "^0.6.2",
"rollup-plugin-terser": "^6.1.0",
"ts-jest": "^26.0.0",
"tslint": "5.20.1",
"tslint-eslint-rules": "^5.4.0",
Expand Down
8 changes: 4 additions & 4 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import nodeResolve from 'rollup-plugin-node-resolve';
import { uglify } from 'rollup-plugin-uglify';
import { terser } from 'rollup-plugin-terser';
import sourcemaps from 'rollup-plugin-sourcemaps';

const MINIFY = process.env.MINIFY;
Expand Down Expand Up @@ -27,9 +27,9 @@ banner += `
* @license MIT License, http://www.opensource.org/licenses/MIT
*/`;

const uglifyOpts = { output: {} };
const terserOpts = { output: {} };
// retain multiline comment with @license
uglifyOpts.output.comments = (node, comment) => comment.type === 'comment2' && /@license/i.test(comment.value);
terserOpts.output.comments = (node, comment) => comment.type === 'comment2' && /@license/i.test(comment.value);

const onwarn = (warning) => {
// Suppress this error message... https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined
Expand All @@ -41,7 +41,7 @@ const onwarn = (warning) => {

const plugins = [nodeResolve({ jsnext: true }), sourcemaps()];

if (MINIFY) plugins.push(uglify(uglifyOpts));
if (MINIFY) plugins.push(terser(terserOpts));

const extension = MINIFY ? '.min.js' : '.js';

Expand Down
Loading

0 comments on commit 4f9a607

Please sign in to comment.