Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit 621090a

Browse files
committed
feat: replace UglifyJs with Terser
1 parent cbba16d commit 621090a

7 files changed

+23
-22
lines changed

Diff for: dependencyManager.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function addProjectDeps(packageJson, force = false) {
2828
};
2929

3030
const depsToAdd = getRequiredDeps(packageJson);
31-
Object.keys(depsToAdd).forEach(function(name) {
31+
Object.keys(depsToAdd).forEach(function (name) {
3232
const version = depsToAdd[name];
3333
Object.assign(postinstallOptions,
3434
addDependency(postinstallOptions.deps, name, version, force));
@@ -54,7 +54,7 @@ function removeObsoleteDeps(packageJson) {
5454
"raw-loader",
5555
"css-loader",
5656
"nativescript-worker-loader",
57-
"uglifyjs-webpack-plugin",
57+
"terser-webpack-plugin",
5858
"@angular-devkit/core",
5959
"resolve-url-loader",
6060
"sass-loader",
@@ -79,12 +79,12 @@ function addDependency(deps, name, version, force) {
7979
}
8080

8181
function getRequiredDeps(packageJson) {
82-
if (!isAngular({packageJson})) {
82+
if (!isAngular({ packageJson })) {
8383
return false;
8484
}
8585

8686
const deps = {
87-
"@angular/compiler-cli": "~7.2.0",
87+
"@angular/compiler-cli": "~7.2.0",
8888
};
8989

9090
if (!dependsOn(packageJson, "@angular-devkit/build-angular")) {

Diff for: package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@
9191
"semver": "5.4.1",
9292
"shelljs": "0.6.0",
9393
"tapable": "1.0.0",
94+
"terser": "3.17.0",
95+
"terser-webpack-plugin": "1.2.3",
9496
"ts-loader": "^5.3.1",
95-
"uglifyjs-webpack-plugin": "~1.2.5",
9697
"webpack": "~4.27.0",
9798
"webpack-bundle-analyzer": "~3.0.2",
9899
"webpack-cli": "~3.1.1",

Diff for: templates/webpack.angular.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const CleanWebpackPlugin = require("clean-webpack-plugin");
1111
const CopyWebpackPlugin = require("copy-webpack-plugin");
1212
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
1313
const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin");
14-
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
14+
const TerserPlugin = require("terser-webpack-plugin");
1515
const { getAngularCompilerPlugin } = require("nativescript-dev-webpack/plugins/NativeScriptAngularCompilerPlugin");
1616
const hashSalt = Date.now().toString();
1717

@@ -165,11 +165,11 @@ module.exports = env => {
165165
},
166166
minimize: !!uglify,
167167
minimizer: [
168-
new UglifyJsPlugin({
168+
new TerserPlugin({
169169
parallel: true,
170170
cache: true,
171171
sourceMap: !!sourceMap || !!hiddenSourceMap,
172-
uglifyOptions: {
172+
terserOptions: {
173173
output: {
174174
comments: false,
175175
},

Diff for: templates/webpack.config.spec.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class AngularCompilerStub {
1717
};
1818

1919
let uglifyJsOptions: any;
20-
class UglifyJsStub {
20+
class TerserJsStub {
2121
constructor(options) {
2222
uglifyJsOptions = options;
2323
}
@@ -50,27 +50,27 @@ const webpackConfigAngular = proxyquire('./webpack.angular', {
5050
'@ngtools/webpack': {
5151
AngularCompilerPlugin: AngularCompilerStub
5252
},
53-
'uglifyjs-webpack-plugin': UglifyJsStub
53+
'terser-webpack-plugin': TerserJsStub
5454
});
5555

5656
const webpackConfigTypeScript = proxyquire('./webpack.typescript', {
5757
'nativescript-dev-webpack': nativeScriptDevWebpack,
5858
'nativescript-dev-webpack/nativescript-target': emptyObject,
59-
'uglifyjs-webpack-plugin': UglifyJsStub
59+
'terser-webpack-plugin': TerserJsStub
6060
});
6161

6262
const webpackConfigJavaScript = proxyquire('./webpack.javascript', {
6363
'nativescript-dev-webpack': nativeScriptDevWebpack,
6464
'nativescript-dev-webpack/nativescript-target': emptyObject,
65-
'uglifyjs-webpack-plugin': UglifyJsStub
65+
'terser-webpack-plugin': TerserJsStub
6666
});
6767

6868
const webpackConfigVue = proxyquire('./webpack.vue', {
6969
'nativescript-dev-webpack': nativeScriptDevWebpack,
7070
'nativescript-dev-webpack/nativescript-target': emptyObject,
7171
'vue-loader/lib/plugin': EmptyClass,
7272
'nativescript-vue-template-compiler': emptyObject,
73-
'uglifyjs-webpack-plugin': UglifyJsStub
73+
'terser-webpack-plugin': TerserJsStub
7474
});
7575

7676
describe('webpack.config.js', () => {

Diff for: templates/webpack.javascript.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const CleanWebpackPlugin = require("clean-webpack-plugin");
77
const CopyWebpackPlugin = require("copy-webpack-plugin");
88
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
99
const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin");
10-
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
10+
const TerserPlugin = require("terser-webpack-plugin");
1111
const hashSalt = Date.now().toString();
1212

1313
module.exports = env => {
@@ -126,11 +126,11 @@ module.exports = env => {
126126
},
127127
minimize: !!uglify,
128128
minimizer: [
129-
new UglifyJsPlugin({
129+
new TerserPlugin({
130130
parallel: true,
131131
cache: true,
132132
sourceMap: !!sourceMap || !!hiddenSourceMap,
133-
uglifyOptions: {
133+
terserOptions: {
134134
output: {
135135
comments: false,
136136
},

Diff for: templates/webpack.typescript.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const CleanWebpackPlugin = require("clean-webpack-plugin");
77
const CopyWebpackPlugin = require("copy-webpack-plugin");
88
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
99
const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin");
10-
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
10+
const TerserPlugin = require("terser-webpack-plugin");
1111
const hashSalt = Date.now().toString();
1212

1313
module.exports = env => {
@@ -128,11 +128,11 @@ module.exports = env => {
128128
},
129129
minimize: !!uglify,
130130
minimizer: [
131-
new UglifyJsPlugin({
131+
new TerserPlugin({
132132
parallel: true,
133133
cache: true,
134134
sourceMap: !!sourceMap || !!hiddenSourceMap,
135-
uglifyOptions: {
135+
terserOptions: {
136136
output: {
137137
comments: false,
138138
},

Diff for: templates/webpack.vue.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const webpack = require("webpack");
44
const CleanWebpackPlugin = require("clean-webpack-plugin");
55
const CopyWebpackPlugin = require("copy-webpack-plugin");
66
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
7-
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
7+
const TerserPlugin = require("terser-webpack-plugin");
88

99
const VueLoaderPlugin = require('vue-loader/lib/plugin');
1010
const NsVueTemplateCompiler = require("nativescript-vue-template-compiler");
@@ -139,11 +139,11 @@ module.exports = env => {
139139
},
140140
minimize: Boolean(production),
141141
minimizer: [
142-
new UglifyJsPlugin({
142+
new TerserPlugin({
143143
parallel: true,
144144
cache: true,
145145
sourceMap: !!sourceMap || !!hiddenSourceMap,
146-
uglifyOptions: {
146+
terserOptions: {
147147
output: {
148148
comments: false,
149149
},

0 commit comments

Comments
 (0)