Skip to content

Commit e9c6800

Browse files
anu-007evenstensberg
authored andcommitted
fix: removes debug in migrate (#342)
1 parent 19249fa commit e9c6800

File tree

3 files changed

+30
-20
lines changed

3 files changed

+30
-20
lines changed

lib/migrate/__snapshots__/index.test.js.snap

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,27 +61,32 @@ module.exports = {
6161
exports[`transform should respect recast options 1`] = `
6262
"
6363
module.exports = {
64-
devtool: 'eval',
65-
entry: [
64+
devtool: 'eval',
65+
66+
entry: [
6667
'./src/index'
6768
],
68-
output: {
69+
70+
output: {
6971
path: path.join(__dirname, 'dist'),
7072
filename: 'index.js'
7173
},
72-
module: {
74+
75+
module: {
7376
rules: [{
74-
test: /.js$/,
77+
test: /\.js$/,
7578
use: [{
7679
loader: \\"babel-loader\\",
7780
}],
7881
include: path.join(__dirname, 'src')
7982
}]
8083
},
81-
resolve: {
84+
85+
resolve: {
8286
modules: ['node_modules', path.resolve('/src')],
8387
},
84-
plugins: [
88+
89+
plugins: [
8590
new webpack.optimize.UglifyJsPlugin({
8691
sourceMap: true,
8792
}),
@@ -90,7 +95,6 @@ module.exports = {
9095
minimize: true,
9196
})
9297
],
93-
debug: true
9498
};
9599
"
96100
`;
@@ -131,36 +135,40 @@ module.exports = {
131135
exports[`transform should transform using all transformations 1`] = `
132136
"
133137
module.exports = {
134-
devtool: 'eval',
135-
entry: [
138+
devtool: 'eval',
139+
140+
entry: [
136141
'./src/index'
137142
],
138-
output: {
143+
144+
output: {
139145
path: path.join(__dirname, 'dist'),
140146
filename: 'index.js'
141147
},
142-
module: {
148+
149+
module: {
143150
rules: [{
144-
test: /.js$/,
151+
test: /\.js$/,
145152
use: [{
146153
loader: 'babel-loader'
147154
}],
148155
include: path.join(__dirname, 'src')
149156
}]
150157
},
151-
resolve: {
158+
159+
resolve: {
152160
modules: ['node_modules', path.resolve('/src')]
153161
},
154-
plugins: [
162+
163+
plugins: [
155164
new webpack.optimize.UglifyJsPlugin({
156165
sourceMap: true
157166
}),
158167
new webpack.LoaderOptionsPlugin({
159168
debug: true,
160169
minimize: true
161170
})
162-
],
163-
debug: true
171+
]
164172
};
165173
"
166174
`;

lib/migrate/loaderOptionsPlugin/__snapshots__/loaderOptionsPlugin.test.js.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ module.exports = {
1212

1313
exports[`loaderOptionsPlugin transforms correctly using "loaderOptionsPlugin-1" data 1`] = `
1414
"module.exports = {
15-
debug: true,
1615
plugins: [
1716
new webpack.optimize.UglifyJsPlugin(),
1817
new webpack.LoaderOptionsPlugin({

lib/migrate/loaderOptionsPlugin/loaderOptionsPlugin.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@ module.exports = function(j, ast) {
1818
const loaderOptions = {};
1919

2020
// If there is debug: true, set debug: true in the plugin
21-
// TODO: remove global debug setting
22-
// TODO: I can't figure out how to find the topmost `debug: true`. help!
2321
if (ast.find(j.Identifier, { name: "debug" }).size()) {
2422
loaderOptions.debug = true;
23+
ast
24+
.find(j.Identifier, { name: "debug" })
25+
.forEach(p => {
26+
p.parent.prune();
27+
});
2528
}
2629

2730
// If there is UglifyJsPlugin, set minimize: true

0 commit comments

Comments
 (0)