Skip to content

Commit

Permalink
Merge pull request #13944 from webpack/bugfix/11594
Browse files Browse the repository at this point in the history
optional modules will not fail the build when bail is set
  • Loading branch information
sokra committed Aug 6, 2021
2 parents 9e735a7 + c6856e2 commit f8acab3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Compilation.js
Original file line number Diff line number Diff line change
Expand Up @@ -1574,10 +1574,11 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
if (err) {
if (dependencies.every(d => d.optional)) {
this.warnings.push(err);
return callback();
} else {
this.errors.push(err);
return callback(err);
}
return callback(err);
}

if (!newModule) {
Expand Down
11 changes: 11 additions & 0 deletions test/configCases/parsing/optional/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
it("should not fail for optional modules with bail", () => {
let error;
try {
require("./not-existing");
} catch (e) {
error = e;
}
expect(() => {
throw error;
}).toThrowError();
});
7 changes: 7 additions & 0 deletions test/configCases/parsing/optional/warnings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = [
[
/Module not found/,
/Can't resolve '\.\/not-existing' /,
{ details: /not-existing\.js/ }
]
];
4 changes: 4 additions & 0 deletions test/configCases/parsing/optional/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
bail: true
};

0 comments on commit f8acab3

Please sign in to comment.