Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: removes debug in migrate #342

Merged
merged 1 commit into from
Mar 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please keep the 'no space' between the two lines, please? I guess this wasn't intentional :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, unless jest did it?!

Copy link
Member

@montogeek montogeek Mar 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a file generated by Jest, __snapshots__ folder

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's why we run prettier on the config after we've written @ematipico . j.literal and j.identifier causes this, no bug.

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