GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix for #8398 - call failed-hook on compilation errors · webpack/webpack@217b2ad

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • Compiler.js
  • test
    • Compiler.test.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/Compiler.js‎

Copy file name to clipboardExpand all lines: lib/Compiler.js
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@ class Compiler extends Tapable {
207207
const finalCallback = (err, stats) => {
208208
this.running = false;
209209

210+
if (err) {
211+
this.hooks.failed.call(err);
212+
}
213+
210214
if (callback !== undefined) return callback(err, stats);
211215
};
212216

Collapse file

‎test/Compiler.test.js‎

Copy file name to clipboardExpand all lines: test/Compiler.test.js
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,4 +493,25 @@ describe("Compiler", () => {
493493
});
494494
});
495495
});
496+
it("should call the failed-hook on error", done => {
497+
const failedSpy = jest.fn();
498+
const compiler = webpack({
499+
bail: true,
500+
context: __dirname,
501+
mode: "production",
502+
entry: "./missing",
503+
output: {
504+
path: "/",
505+
filename: "bundle.js"
506+
},
507+
});
508+
compiler.hooks.failed.tap('CompilerTest', failedSpy);
509+
compiler.outputFileSystem = new MemoryFs();
510+
compiler.run((err, stats) => {
511+
expect(err).toBeTruthy();
512+
expect(failedSpy).toHaveBeenCalledTimes(1);
513+
expect(failedSpy).toHaveBeenCalledWith(err);
514+
done();
515+
});
516+
});
496517
});

0 commit comments

Comments
0 (0)
You are visitor 01402605 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.