Skip to content

Commit

Permalink
fix: stats.hasWarnings() respects ignoreWarnings
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Apr 12, 2024
2 parents d0ee82b + 2cf4283 commit 0f7dedd
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Stats.js
Expand Up @@ -35,7 +35,7 @@ class Stats {
*/
hasWarnings() {
return (
this.compilation.warnings.length > 0 ||
this.compilation.getWarnings().length > 0 ||
this.compilation.children.some(child => child.getStats().hasWarnings())
);
}
Expand Down
16 changes: 16 additions & 0 deletions test/Stats.test.js
Expand Up @@ -62,6 +62,22 @@ describe("Stats", () => {
})
).toEqual({});
});
it("should the results of hasWarnings() be affected by ignoreWarnings", async () => {
const stats = await compile({
mode: "development",
context: __dirname,
entry: "./fixtures/ignoreWarnings/index",
module: {
rules: [
{
loader: "./fixtures/ignoreWarnings/loader"
}
]
},
ignoreWarnings: [/__mocked__warning__/]
});
expect(stats.hasWarnings()).toBeFalsy();
});
describe("chunkGroups", () => {
it("should be empty when there is no additional chunks", async () => {
const stats = await compile({
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/ignoreWarnings/index.js
@@ -0,0 +1,3 @@
module.exports = function ignoreWarnings() {
return "This is ignoreWarnings";
};
4 changes: 4 additions & 0 deletions test/fixtures/ignoreWarnings/loader.js
@@ -0,0 +1,4 @@
module.exports = function wraningLoader(content) {
this.emitWarning('__mocked__warning__');
return content;
};

0 comments on commit 0f7dedd

Please sign in to comment.