Skip to content

Commit

Permalink
fix: removes debug in migrate
Browse files Browse the repository at this point in the history
  • Loading branch information
anu-007 committed Mar 13, 2018
1 parent 19249fa commit 2731941
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 20 deletions.
42 changes: 25 additions & 17 deletions lib/migrate/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
Expand All @@ -90,7 +95,6 @@ module.exports = {
minimize: true,
})
],
debug: true
};
"
`;
Expand Down Expand Up @@ -131,36 +135,40 @@ 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
}),
new webpack.LoaderOptionsPlugin({
debug: true,
minimize: true
})
],
debug: true
]
};
"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
7 changes: 5 additions & 2 deletions lib/migrate/loaderOptionsPlugin/loaderOptionsPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2731941

Please sign in to comment.