Skip to content

Commit e6afd23

Browse files
author
Steven Hargrove
committed
added tests for swallowed loader errors, fixed another swallowed error
1 parent 21af619 commit e6afd23

File tree

4 files changed

+64
-4
lines changed

4 files changed

+64
-4
lines changed

lib/Compilation.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,8 @@ class Compilation {
931931
return callback(err);
932932
}
933933

934+
if (module.error) return callback(module.error);
935+
934936
// This avoids deadlocks for circular dependencies
935937
if (this.processDependenciesQueue.isProcessing(module)) {
936938
return callback();
@@ -1067,14 +1069,12 @@ class Compilation {
10671069
},
10681070
err => {
10691071
if (this.bail) {
1070-
const result = callback(err);
1071-
1072+
callback(err);
10721073
this.buildQueue.stop();
10731074
this.rebuildQueue.stop();
10741075
this.processDependenciesQueue.stop();
10751076
this.factorizeQueue.stop();
1076-
1077-
return result;
1077+
return;
10781078
}
10791079
return callback();
10801080
}

test/Errors.test.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,64 @@ describe("Errors", () => {
304304
);
305305
}
306306
),
307+
getErrorsPromise(
308+
{
309+
mode: "development",
310+
entry: "./entry-point.js",
311+
module: {
312+
rules: [
313+
{
314+
test: /entry-point\.js$/,
315+
use: path.resolve(base, "./doesnt-exist-loader")
316+
}
317+
]
318+
}
319+
},
320+
(errors, warnings) => {
321+
expect(errors).toHaveLength(1);
322+
expect(errors[0]).toMatch(/^Module not found/);
323+
}
324+
),
325+
getErrorsPromise(
326+
{
327+
mode: "development",
328+
entry: "./entry-point.js",
329+
module: {
330+
rules: [
331+
{
332+
test: /entry-point\.js$/,
333+
use: path.resolve(base, "./return-undefined-loader")
334+
}
335+
]
336+
}
337+
},
338+
(errors, warnings) => {
339+
expect(errors).toHaveLength(1);
340+
expect(errors[0].split("\n")[1]).toMatch(
341+
/^Module build failed: Error: Final loader \(\.\/return-undefined-loader\.js\) didn't return a Buffer or String$/
342+
);
343+
}
344+
),
345+
getErrorsPromise(
346+
{
347+
mode: "development",
348+
entry: "./entry-point.js",
349+
module: {
350+
rules: [
351+
{
352+
test: /entry-point\.js$/,
353+
use: path.resolve(base, "./module-exports-object-loader")
354+
}
355+
]
356+
}
357+
},
358+
(errors, warnings) => {
359+
expect(errors).toHaveLength(1);
360+
expect(errors[0].split("\n")[1]).toMatch(
361+
/^Module '.*\/module-exports-object-loader\.js' is not a loader \(must have normal or pitch function\)$/
362+
);
363+
}
364+
),
307365
getErrorsPromise(
308366
{
309367
mode: "development",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = {};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = () => {};

0 commit comments

Comments
 (0)