-
-
Notifications
You must be signed in to change notification settings - Fork 601
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
Add NoEmitOnErrorsPlugin transformation #399
Merged
evenstensberg
merged 3 commits into
webpack:master
from
bitpshr:feature/v3-v4-noEmitOnErrorsPlugin
Apr 15, 2018
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
lib/migrate/moduleConcatenationPlugin/__snapshots__/moduleConcatenationPlugin.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`moduleConcatenationPlugin transforms correctly using "moduleConcatenationPlugin-0" data 1`] = ` | ||
"module.export = { | ||
optimizations: { | ||
concatenateModules: true | ||
} | ||
} | ||
" | ||
`; | ||
|
||
exports[`moduleConcatenationPlugin transforms correctly using "moduleConcatenationPlugin-1" data 1`] = ` | ||
"module.export = { | ||
optimizations: { | ||
splitChunks: false, | ||
concatenateModules: true | ||
}, | ||
plugins: [new Foo()] | ||
} | ||
" | ||
`; | ||
|
||
exports[`moduleConcatenationPlugin transforms correctly using "moduleConcatenationPlugin-2" data 1`] = ` | ||
"module.export = { | ||
optimizations: { | ||
concatenateModules: true | ||
}, | ||
plugins: [new Foo()] | ||
} | ||
" | ||
`; | ||
3 changes: 3 additions & 0 deletions
3
lib/migrate/moduleConcatenationPlugin/__testfixtures__/.editorconfig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[*] | ||
indent_style = space | ||
indent_size = 4 |
5 changes: 5 additions & 0 deletions
5
lib/migrate/moduleConcatenationPlugin/__testfixtures__/moduleConcatenationPlugin-0.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.export = { | ||
plugins: [ | ||
new webpack.optimize.ModuleConcatenationPlugin() | ||
] | ||
} |
9 changes: 9 additions & 0 deletions
9
lib/migrate/moduleConcatenationPlugin/__testfixtures__/moduleConcatenationPlugin-1.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.export = { | ||
optimizations: { | ||
splitChunks: false | ||
}, | ||
plugins: [ | ||
new Foo(), | ||
new webpack.optimize.ModuleConcatenationPlugin() | ||
] | ||
} |
9 changes: 9 additions & 0 deletions
9
lib/migrate/moduleConcatenationPlugin/__testfixtures__/moduleConcatenationPlugin-2.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.export = { | ||
optimizations: { | ||
concatenateModules: false | ||
}, | ||
plugins: [ | ||
new Foo(), | ||
new webpack.optimize.ModuleConcatenationPlugin() | ||
] | ||
} |
34 changes: 34 additions & 0 deletions
34
lib/migrate/moduleConcatenationPlugin/moduleConcatenationPlugin.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const { | ||
addOrUpdateConfigObject, | ||
findAndRemovePluginByName | ||
} = require("../../utils/ast-utils"); | ||
|
||
/** | ||
* | ||
* Transform for NamedModulesPlugin. If found, removes the | ||
* plugin and sets optimizations.namedModules to true | ||
* | ||
* @param {Object} j - jscodeshift top-level import | ||
* @param {Node} ast - jscodeshift ast to transform | ||
* @returns {Node} ast - jscodeshift ast | ||
*/ | ||
module.exports = function(j, ast) { | ||
// Remove old plugin | ||
const root = findAndRemovePluginByName( | ||
j, | ||
ast, | ||
"webpack.optimize.ModuleConcatenationPlugin" | ||
); | ||
|
||
// Add new optimizations option | ||
root && | ||
addOrUpdateConfigObject( | ||
j, | ||
root, | ||
"optimizations", | ||
"concatenateModules", | ||
j.booleanLiteral(true) | ||
); | ||
|
||
return ast; | ||
}; |
19 changes: 19 additions & 0 deletions
19
lib/migrate/moduleConcatenationPlugin/moduleConcatenationPlugin.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"use strict"; | ||
|
||
const defineTest = require("../../utils/defineTest"); | ||
|
||
defineTest( | ||
__dirname, | ||
"moduleConcatenationPlugin", | ||
"moduleConcatenationPlugin-0" | ||
); | ||
defineTest( | ||
__dirname, | ||
"moduleConcatenationPlugin", | ||
"moduleConcatenationPlugin-1" | ||
); | ||
defineTest( | ||
__dirname, | ||
"moduleConcatenationPlugin", | ||
"moduleConcatenationPlugin-2" | ||
); |
31 changes: 31 additions & 0 deletions
31
lib/migrate/namedModulesPlugin/__snapshots__/namedModulesPlugin.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`namedModulesPlugin transforms correctly using "namedModulesPlugin-0" data 1`] = ` | ||
"module.export = { | ||
optimizations: { | ||
namedModules: true | ||
} | ||
} | ||
" | ||
`; | ||
|
||
exports[`namedModulesPlugin transforms correctly using "namedModulesPlugin-1" data 1`] = ` | ||
"module.export = { | ||
optimizations: { | ||
splitChunks: false, | ||
namedModules: true | ||
}, | ||
plugins: [new Foo()] | ||
} | ||
" | ||
`; | ||
|
||
exports[`namedModulesPlugin transforms correctly using "namedModulesPlugin-2" data 1`] = ` | ||
"module.export = { | ||
optimizations: { | ||
namedModules: true | ||
}, | ||
plugins: [new Foo()] | ||
} | ||
" | ||
`; |
3 changes: 3 additions & 0 deletions
3
lib/migrate/namedModulesPlugin/__testfixtures__/.editorconfig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[*] | ||
indent_style = space | ||
indent_size = 4 |
5 changes: 5 additions & 0 deletions
5
lib/migrate/namedModulesPlugin/__testfixtures__/namedModulesPlugin-0.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.export = { | ||
plugins: [ | ||
new webpack.NamedModulesPlugin() | ||
] | ||
} |
9 changes: 9 additions & 0 deletions
9
lib/migrate/namedModulesPlugin/__testfixtures__/namedModulesPlugin-1.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.export = { | ||
optimizations: { | ||
splitChunks: false | ||
}, | ||
plugins: [ | ||
new Foo(), | ||
new webpack.NamedModulesPlugin() | ||
] | ||
} |
9 changes: 9 additions & 0 deletions
9
lib/migrate/namedModulesPlugin/__testfixtures__/namedModulesPlugin-2.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.export = { | ||
optimizations: { | ||
namedModules: false | ||
}, | ||
plugins: [ | ||
new Foo(), | ||
new webpack.NamedModulesPlugin() | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const { | ||
addOrUpdateConfigObject, | ||
findAndRemovePluginByName | ||
} = require("../../utils/ast-utils"); | ||
|
||
/** | ||
* | ||
* Transform for NamedModulesPlugin. If found, removes the | ||
* plugin and sets optimizations.namedModules to true | ||
* | ||
* @param {Object} j - jscodeshift top-level import | ||
* @param {Node} ast - jscodeshift ast to transform | ||
* @returns {Node} ast - jscodeshift ast | ||
*/ | ||
module.exports = function(j, ast) { | ||
// Remove old plugin | ||
const root = findAndRemovePluginByName(j, ast, "webpack.NamedModulesPlugin"); | ||
|
||
// Add new optimizations option | ||
root && | ||
addOrUpdateConfigObject( | ||
j, | ||
root, | ||
"optimizations", | ||
"namedModules", | ||
j.booleanLiteral(true) | ||
); | ||
|
||
return ast; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"use strict"; | ||
|
||
const defineTest = require("../../utils/defineTest"); | ||
|
||
defineTest(__dirname, "namedModulesPlugin", "namedModulesPlugin-0"); | ||
defineTest(__dirname, "namedModulesPlugin", "namedModulesPlugin-1"); | ||
defineTest(__dirname, "namedModulesPlugin", "namedModulesPlugin-2"); |
31 changes: 31 additions & 0 deletions
31
lib/migrate/noEmitOnErrorsPlugin/__snapshots__/noEmitOnErrorsPlugin.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`noEmitOnErrorsPlugin transforms correctly using "noEmitOnErrorsPlugin-0" data 1`] = ` | ||
"module.export = { | ||
optimizations: { | ||
noEmitOnErrors: true | ||
} | ||
} | ||
" | ||
`; | ||
|
||
exports[`noEmitOnErrorsPlugin transforms correctly using "noEmitOnErrorsPlugin-1" data 1`] = ` | ||
"module.export = { | ||
optimizations: { | ||
splitChunks: false, | ||
noEmitOnErrors: true | ||
}, | ||
plugins: [new Foo()] | ||
} | ||
" | ||
`; | ||
|
||
exports[`noEmitOnErrorsPlugin transforms correctly using "noEmitOnErrorsPlugin-2" data 1`] = ` | ||
"module.export = { | ||
optimizations: { | ||
noEmitOnErrors: true | ||
}, | ||
plugins: [new Foo()] | ||
} | ||
" | ||
`; |
3 changes: 3 additions & 0 deletions
3
lib/migrate/noEmitOnErrorsPlugin/__testfixtures__/.editorconfig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[*] | ||
indent_style = space | ||
indent_size = 4 |
5 changes: 5 additions & 0 deletions
5
lib/migrate/noEmitOnErrorsPlugin/__testfixtures__/noEmitOnErrorsPlugin-0.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.export = { | ||
plugins: [ | ||
new webpack.NoEmitOnErrorsPlugin() | ||
] | ||
} |
9 changes: 9 additions & 0 deletions
9
lib/migrate/noEmitOnErrorsPlugin/__testfixtures__/noEmitOnErrorsPlugin-1.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.export = { | ||
optimizations: { | ||
splitChunks: false | ||
}, | ||
plugins: [ | ||
new Foo(), | ||
new webpack.NoEmitOnErrorsPlugin() | ||
] | ||
} |
9 changes: 9 additions & 0 deletions
9
lib/migrate/noEmitOnErrorsPlugin/__testfixtures__/noEmitOnErrorsPlugin-2.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.export = { | ||
optimizations: { | ||
noEmitOnErrors: false | ||
}, | ||
plugins: [ | ||
new Foo(), | ||
new webpack.NoEmitOnErrorsPlugin() | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const { | ||
addOrUpdateConfigObject, | ||
findAndRemovePluginByName | ||
} = require("../../utils/ast-utils"); | ||
|
||
/** | ||
* | ||
* Transform for NoEmitOnErrorsPlugin. If found, removes the | ||
* plugin and sets optimizations.noEmitOnErrors to true | ||
* | ||
* @param {Object} j - jscodeshift top-level import | ||
* @param {Node} ast - jscodeshift ast to transform | ||
* @returns {Node} ast - jscodeshift ast | ||
*/ | ||
module.exports = function(j, ast) { | ||
// Remove old plugin | ||
const root = findAndRemovePluginByName( | ||
j, | ||
ast, | ||
"webpack.NoEmitOnErrorsPlugin" | ||
); | ||
|
||
// Add new optimizations option | ||
root && | ||
addOrUpdateConfigObject( | ||
j, | ||
root, | ||
"optimizations", | ||
"noEmitOnErrors", | ||
j.booleanLiteral(true) | ||
); | ||
|
||
return ast; | ||
}; |
7 changes: 7 additions & 0 deletions
7
lib/migrate/noEmitOnErrorsPlugin/noEmitOnErrorsPlugin.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"use strict"; | ||
|
||
const defineTest = require("../../utils/defineTest"); | ||
|
||
defineTest(__dirname, "noEmitOnErrorsPlugin", "noEmitOnErrorsPlugin-0"); | ||
defineTest(__dirname, "noEmitOnErrorsPlugin", "noEmitOnErrorsPlugin-1"); | ||
defineTest(__dirname, "noEmitOnErrorsPlugin", "noEmitOnErrorsPlugin-2"); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!