Skip to content

Commit 9863445

Browse files
abenezerabebesendilkumarn
authored andcommittedMar 16, 2019
fix: reset files
Move files back to uglify
1 parent ef23fec commit 9863445

20 files changed

+398
-82
lines changed
 

‎MIGRATE.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Given a basic configuration file like so:
3434
const ExtractTextPlugin = require('extract-text-webpack-plugin');
3535
const HtmlWebpackPlugin = require('html-webpack-plugin');
3636
const path = require('path');
37-
const TerserPlugin = require('terser-webpack-plugin');
37+
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
3838
const webpack = require('webpack');
3939

4040
module.exports = {
@@ -68,7 +68,7 @@ module.exports = {
6868
},
6969

7070
plugins: [
71-
new TerserPlugin(),
71+
new UglifyJSPlugin(),
7272

7373
new ExtractTextPlugin('styles-[contentHash].css'),
7474

@@ -115,7 +115,7 @@ After it has run, we have our new webpack config file!
115115
const ExtractTextPlugin = require('extract-text-webpack-plugin');
116116
const HtmlWebpackPlugin = require('html-webpack-plugin');
117117
const path = require('path');
118-
const TerserPlugin = require('terser-webpack-plugin');
118+
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
119119
const webpack = require('webpack');
120120

121121
module.exports = {
@@ -154,7 +154,7 @@ module.exports = {
154154
},
155155

156156
plugins: [
157-
new TerserPlugin(),
157+
new UglifyJSPlugin(),
158158

159159
new ExtractTextPlugin('styles-[contentHash].css'),
160160

‎package-lock.json

-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/generators/init-generator.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default class InitGenerator extends Generator {
4343
this.dependencies = [
4444
"webpack",
4545
"webpack-cli",
46-
"terser-webpack-plugin",
46+
"uglifyjs-webpack-plugin",
4747
"babel-plugin-syntax-dynamic-import",
4848
];
4949
this.configuration = {
@@ -430,12 +430,12 @@ export default class InitGenerator extends Generator {
430430
public installPlugins() {
431431
if (this.isProd) {
432432
this.dependencies = this.dependencies.filter(
433-
(p: string) => p !== "terser-webpack-plugin",
433+
(p: string) => p !== "uglifyjs-webpack-plugin",
434434
);
435435
} else {
436436
this.configuration.config.topScope.push(
437-
tooltip.terser(),
438-
"const TerserPlugin = require('terser-webpack-plugin');",
437+
tooltip.uglify(),
438+
"const UglifyJSPlugin = require('uglifyjs-webpack-plugin');",
439439
"\n",
440440
);
441441
}

‎packages/generators/utils/plugins.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
* Callable function with the initial plugins
44
*
55
* @returns {Function} An function that returns an array
6-
* that consists of the terser plugin
6+
* that consists of the uglify plugin
77
*/
88

99
export default function(_?: void): string[] {
10-
return ["new TerserPlugin()"];
10+
return ["new UglifyJSPlugin()"];
1111
}

‎packages/generators/utils/tooltip.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ export default {
5050
*/`;
5151
},
5252

53-
terser: (_?: void): string => {
53+
uglify: (_?: void): string => {
5454
return `/*
55-
* We've enabled TerserJSPlugin for you! This minifies your app
55+
* We've enabled UglifyJSPlugin for you! This minifies your app
5656
* in order to load faster and run less javascript.
5757
*
58-
* https://github.com/webpack-contrib/terser-webpack-plugin
58+
* https://github.com/webpack-contrib/uglifyjs-webpack-plugin
5959
*
6060
*/`;
6161
},

‎packages/migrate/__testfixtures__/failing.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const webpack = require('webpack');
22
const nodeEnvironment = process.env.NODE_ENV;
33
const _ = require("lodash");
4-
const TerserPlugin = require('terser-webpack-plugin');
54

65
const config = {
76
entry: {
@@ -44,7 +43,7 @@ const config = {
4443

4544
switch (nodeEnvironment) {
4645
case "production":
47-
config.plugins.push(new TerserPlugin());
46+
config.plugins.push(new webpack.optimize.UglifyJsPlugin());
4847
case "preproduction":
4948
config.output.path = __dirname + "/dist";
5049
config.plugins.push(new webpack.optimize.DedupePlugin());

‎packages/migrate/__tests__/__snapshots__/migrate.test.ts.snap

+25-37
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = {
2222
modules: ['node_modules']
2323
},
2424
plugins: [
25-
new TerserPlugin(),
25+
new webpack.optimize.UglifyJsPlugin(),
2626
new webpack.optimize.OccurrenceOrderPlugin()
2727
],
2828
debug: true
@@ -50,7 +50,7 @@ module.exports = {
5050
modules: ['node_modules']
5151
},
5252
plugins: [
53-
new TerserPlugin(),
53+
new webpack.optimize.UglifyJsPlugin(),
5454
new webpack.optimize.OccurrenceOrderPlugin()
5555
],
5656
debug: true
@@ -61,18 +61,15 @@ module.exports = {
6161
exports[`transform should respect recast options 1`] = `
6262
"
6363
module.exports = {
64-
devtool: 'eval',
65-
66-
entry: [
64+
devtool: 'eval',
65+
entry: [
6766
'./src/index'
6867
],
69-
70-
output: {
68+
output: {
7169
path: path.join(__dirname, 'dist'),
7270
filename: 'index.js'
7371
},
74-
75-
module: {
72+
module: {
7673
rules: [{
7774
test: /.js$/,
7875
use: [{
@@ -81,18 +78,15 @@ module.exports = {
8178
include: path.join(__dirname, 'src')
8279
}]
8380
},
84-
85-
resolve: {
81+
resolve: {
8682
modules: ['node_modules', path.resolve('/src')],
8783
},
88-
89-
plugins: [
90-
new TerserPlugin(),
91-
new webpack.LoaderOptionsPlugin({
92-
debug: true,
93-
minimize: true,
94-
})
95-
],
84+
plugins: [new webpack.LoaderOptionsPlugin({
85+
debug: true,
86+
})],
87+
optimization: {
88+
minimize: true,
89+
}
9690
};
9791
"
9892
`;
@@ -122,7 +116,7 @@ module.exports = {
122116
modules: ['node_modules']
123117
},
124118
plugins: [
125-
new TerserPlugin(),
119+
new webpack.optimize.UglifyJsPlugin(),
126120
new webpack.optimize.OccurrenceOrderPlugin()
127121
],
128122
debug: true
@@ -133,18 +127,15 @@ module.exports = {
133127
exports[`transform should transform using all transformations 1`] = `
134128
"
135129
module.exports = {
136-
devtool: 'eval',
137-
138-
entry: [
130+
devtool: 'eval',
131+
entry: [
139132
'./src/index'
140133
],
141-
142-
output: {
134+
output: {
143135
path: path.join(__dirname, 'dist'),
144136
filename: 'index.js'
145137
},
146-
147-
module: {
138+
module: {
148139
rules: [{
149140
test: /.js$/,
150141
use: [{
@@ -153,18 +144,15 @@ module.exports = {
153144
include: path.join(__dirname, 'src')
154145
}]
155146
},
156-
157-
resolve: {
147+
resolve: {
158148
modules: ['node_modules', path.resolve('/src')]
159149
},
160-
161-
plugins: [
162-
new TerserPlugin(),
163-
new webpack.LoaderOptionsPlugin({
164-
debug: true,
165-
minimize: true
166-
})
167-
]
150+
plugins: [new webpack.LoaderOptionsPlugin({
151+
debug: true
152+
})],
153+
optimization: {
154+
minimize: true
155+
}
168156
};
169157
"
170158
`;

‎packages/migrate/loaderOptionsPlugin/__tests__/__snapshots__/loaderOptionsPlugin.test.ts.snap

+4-5
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,15 @@ module.exports = {
1111
`;
1212

1313
exports[`loaderOptionsPlugin transforms correctly using "loaderOptionsPlugin-1" data 1`] = `
14-
"const TerserPlugin = require(\\"terser-webpack-plugin\\");
15-
module.exports = {
14+
"module.exports = {
1615
plugins: [
17-
new TerserPlugin(),
18-
new webpack.LoaderOptionsPlugin({
16+
new webpack.optimize.UglifyJsPlugin(),
17+
new webpack.LoaderOptionsPlugin({
1918
foo: 'bar',
2019
debug: true,
2120
minimize: true
2221
})
23-
]
22+
]
2423
}
2524
"
2625
`;
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
const TerserPlugin = require("terser-webpack-plugin");
21
module.exports = {
3-
debug: true,
4-
plugins: [
5-
new TerserPlugin(),
6-
new webpack.LoaderOptionsPlugin({
7-
foo: 'bar'
8-
})
9-
]
2+
debug: true,
3+
plugins: [
4+
new webpack.optimize.UglifyJsPlugin(),
5+
new webpack.LoaderOptionsPlugin({
6+
foo: 'bar'
7+
})
8+
]
109
}

‎packages/migrate/loaderOptionsPlugin/loaderOptionsPlugin.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ export default function(j: IJSCodeshift, ast: INode): INode {
3737
});
3838
}
3939

40-
// If there is TerserPlugin, set minimize: true
41-
if (findPluginsByName(j, ast, ["TerserPlugin"]).size()) {
40+
// If there is UglifyJsPlugin, set minimize: true
41+
if (findPluginsByName(j, ast, ["webpack.optimize.UglifyJsPlugin"]).size()) {
4242
loaderOptions.minimize = true;
4343
}
4444

‎packages/migrate/migrate.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import noEmitOnErrorsPluginTransform from "./noEmitOnErrorsPlugin/noEmitOnErrors
1111
import removeDeprecatedPluginsTransform from "./removeDeprecatedPlugins/removeDeprecatedPlugins";
1212
import removeJsonLoaderTransform from "./removeJsonLoader/removeJsonLoader";
1313
import resolveTransform from "./resolve/resolve";
14-
import terserPluginTransform from "./terserPlugin/terserPlugin";
1514
import { INode } from "./types/NodePath";
15+
import uglifyJsPluginTransform from "./uglifyJsPlugin/uglifyJsPlugin";
1616

1717
interface ITransformsObject {
1818
bannerPluginTransform: object;
@@ -24,15 +24,15 @@ interface ITransformsObject {
2424
removeDeprecatedPluginsTransform: object;
2525
removeJsonLoaderTransform: object;
2626
resolveTransform: object;
27-
terserPluginTransform: object;
27+
uglifyJsPluginTransform: object;
2828
}
2929

3030
/* tslint:disable object-literal-sort-keys */
3131
const transformsObject: ITransformsObject = {
3232
loadersTransform,
3333
resolveTransform,
3434
removeJsonLoaderTransform,
35-
terserPluginTransform,
35+
uglifyJsPluginTransform,
3636
loaderOptionsPluginTransform,
3737
bannerPluginTransform,
3838
extractTextPluginTransform,

0 commit comments

Comments
 (0)
Please sign in to comment.