@@ -15,7 +15,8 @@ import { IJSCodeshift, INode } from "../types/NodePath";
1515 * and adds `optimization.minimize: true` to config
1616 *
1717 * 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`.
1920 *
2021 * @param {Object } j - jscodeshift top-level import
2122 * @param {Node } ast - jscodeshift ast to transform
@@ -63,15 +64,15 @@ export default function(j: IJSCodeshift, ast: INode): INode {
6364 * If user is using UglifyJsPlugin directly from webpack
6465 * transformation must:
6566 * - remove it
66- * - add require for uglify -webpack-plugin
67+ * - add require for terser -webpack-plugin
6768 * - add to minimizer
6869 */
6970 if ( pluginVariableAssignment && pluginVariableAssignment . includes ( "webpack" ) ) {
70- // create require for uglify -webpack-plugin
71+ // create require for terser -webpack-plugin
7172 const pathRequire : INode = getRequire (
7273 j ,
73- "UglifyJsPlugin " ,
74- "uglifyjs -webpack-plugin" ,
74+ "TerserPlugin " ,
75+ "terser -webpack-plugin" ,
7576 ) ;
7677 // append to source code.
7778 ast
@@ -84,7 +85,7 @@ export default function(j: IJSCodeshift, ast: INode): INode {
8485 "init" ,
8586 j . identifier ( "minimizer" ) ,
8687 j . arrayExpression ( [
87- j . newExpression ( j . identifier ( "UglifyJsPlugin " ) , [ pluginOptions [ 0 ] ] ) ,
88+ j . newExpression ( j . identifier ( "TerserPlugin " ) , [ pluginOptions [ 0 ] ] ) ,
8889 ] ) ,
8990 ) ;
9091 } else {
0 commit comments