optional modules will not fail the build when bail is set

fixes #11594
This commit is contained in:
Tobias Koppers 2021-08-06 12:09:55 +02:00
parent a6e9f59dfc
commit c6856e2204
4 changed files with 24 additions and 1 deletions

View File

@ -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) {

View File

@ -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();
});

View File

@ -0,0 +1,7 @@
module.exports = [
[
/Module not found/,
/Can't resolve '\.\/not-existing' /,
{ details: /not-existing\.js/ }
]
];

View File

@ -0,0 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
bail: true
};