diff --git a/lib/migrate/__snapshots__/index.test.js.snap b/lib/migrate/__snapshots__/index.test.js.snap index 99b88db2e40..ab4675fb08a 100644 --- a/lib/migrate/__snapshots__/index.test.js.snap +++ b/lib/migrate/__snapshots__/index.test.js.snap @@ -61,27 +61,32 @@ module.exports = { exports[`transform should respect recast options 1`] = ` " module.exports = { - devtool: 'eval', - entry: [ + devtool: 'eval', + + entry: [ './src/index' ], - output: { + + output: { path: path.join(__dirname, 'dist'), filename: 'index.js' }, - module: { + + module: { rules: [{ - test: /.js$/, + test: /\.js$/, use: [{ loader: \\"babel-loader\\", }], include: path.join(__dirname, 'src') }] }, - resolve: { + + resolve: { modules: ['node_modules', path.resolve('/src')], }, - plugins: [ + + plugins: [ new webpack.optimize.UglifyJsPlugin({ sourceMap: true, }), @@ -90,7 +95,6 @@ module.exports = { minimize: true, }) ], - debug: true }; " `; @@ -131,27 +135,32 @@ module.exports = { exports[`transform should transform using all transformations 1`] = ` " module.exports = { - devtool: 'eval', - entry: [ + devtool: 'eval', + + entry: [ './src/index' ], - output: { + + output: { path: path.join(__dirname, 'dist'), filename: 'index.js' }, - module: { + + module: { rules: [{ - test: /.js$/, + test: /\.js$/, use: [{ loader: 'babel-loader' }], include: path.join(__dirname, 'src') }] }, - resolve: { + + resolve: { modules: ['node_modules', path.resolve('/src')] }, - plugins: [ + + plugins: [ new webpack.optimize.UglifyJsPlugin({ sourceMap: true }), @@ -159,8 +168,7 @@ module.exports = { debug: true, minimize: true }) - ], - debug: true + ] }; " `; diff --git a/lib/migrate/loaderOptionsPlugin/__snapshots__/loaderOptionsPlugin.test.js.snap b/lib/migrate/loaderOptionsPlugin/__snapshots__/loaderOptionsPlugin.test.js.snap index c6d8d48b157..cb72fbea538 100644 --- a/lib/migrate/loaderOptionsPlugin/__snapshots__/loaderOptionsPlugin.test.js.snap +++ b/lib/migrate/loaderOptionsPlugin/__snapshots__/loaderOptionsPlugin.test.js.snap @@ -12,7 +12,6 @@ module.exports = { exports[`loaderOptionsPlugin transforms correctly using "loaderOptionsPlugin-1" data 1`] = ` "module.exports = { - debug: true, plugins: [ new webpack.optimize.UglifyJsPlugin(), new webpack.LoaderOptionsPlugin({ diff --git a/lib/migrate/loaderOptionsPlugin/loaderOptionsPlugin.js b/lib/migrate/loaderOptionsPlugin/loaderOptionsPlugin.js index 5019aeeed79..e7daf5c45b1 100644 --- a/lib/migrate/loaderOptionsPlugin/loaderOptionsPlugin.js +++ b/lib/migrate/loaderOptionsPlugin/loaderOptionsPlugin.js @@ -18,10 +18,13 @@ module.exports = function(j, ast) { const loaderOptions = {}; // If there is debug: true, set debug: true in the plugin - // TODO: remove global debug setting - // TODO: I can't figure out how to find the topmost `debug: true`. help! if (ast.find(j.Identifier, { name: "debug" }).size()) { loaderOptions.debug = true; + ast + .find(j.Identifier, { name: "debug" }) + .forEach(p => { + p.parent.prune(); + }); } // If there is UglifyJsPlugin, set minimize: true