@@ -15,7 +15,8 @@ import { IJSCodeshift, INode } from "../types/NodePath";
15
15
* and adds `optimization.minimize: true` to config
16
16
*
17
17
* If any configuration is passed to UglifyWebpackPlugin
18
- * plugin instantiation is moved to `optimization.minimizer`.
18
+ * Replaces UglifyWebpackPlugin with TerserPlugin and
19
+ * and moves plugin instantiation to `optimization.minimizer`.
19
20
*
20
21
* @param {Object } j - jscodeshift top-level import
21
22
* @param {Node } ast - jscodeshift ast to transform
@@ -63,15 +64,15 @@ export default function(j: IJSCodeshift, ast: INode): INode {
63
64
* If user is using UglifyJsPlugin directly from webpack
64
65
* transformation must:
65
66
* - remove it
66
- * - add require for uglify -webpack-plugin
67
+ * - add require for terser -webpack-plugin
67
68
* - add to minimizer
68
69
*/
69
70
if ( pluginVariableAssignment && pluginVariableAssignment . includes ( "webpack" ) ) {
70
- // create require for uglify -webpack-plugin
71
+ // create require for terser -webpack-plugin
71
72
const pathRequire : INode = getRequire (
72
73
j ,
73
- "UglifyJsPlugin " ,
74
- "uglifyjs -webpack-plugin" ,
74
+ "TerserPlugin " ,
75
+ "terser -webpack-plugin" ,
75
76
) ;
76
77
// append to source code.
77
78
ast
@@ -84,7 +85,7 @@ export default function(j: IJSCodeshift, ast: INode): INode {
84
85
"init" ,
85
86
j . identifier ( "minimizer" ) ,
86
87
j . arrayExpression ( [
87
- j . newExpression ( j . identifier ( "UglifyJsPlugin " ) , [ pluginOptions [ 0 ] ] ) ,
88
+ j . newExpression ( j . identifier ( "TerserPlugin " ) , [ pluginOptions [ 0 ] ] ) ,
88
89
] ) ,
89
90
) ;
90
91
} else {
0 commit comments