Skip to content

Commit 82b7428

Browse files
author
Steven Hargrove
committed
rewrite errors tests, cleanup, update snapshots
1 parent e6afd23 commit 82b7428

File tree

8 files changed

+724
-410
lines changed

8 files changed

+724
-410
lines changed

lib/Compilation.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const ModuleTemplate = require("./ModuleTemplate");
3939
const RuntimeGlobals = require("./RuntimeGlobals");
4040
const RuntimeTemplate = require("./RuntimeTemplate");
4141
const Stats = require("./Stats");
42+
const WebpackError = require("./WebpackError");
4243
const StatsFactory = require("./stats/StatsFactory");
4344
const StatsPrinter = require("./stats/StatsPrinter");
4445
const AsyncQueue = require("./util/AsyncQueue");
@@ -931,8 +932,6 @@ class Compilation {
931932
return callback(err);
932933
}
933934

934-
if (module.error) return callback(module.error);
935-
936935
// This avoids deadlocks for circular dependencies
937936
if (this.processDependenciesQueue.isProcessing(module)) {
938937
return callback();
@@ -1048,15 +1047,19 @@ class Compilation {
10481047
dependency === null ||
10491048
!dependency.constructor
10501049
) {
1051-
throw new Error("Parameter 'dependency' must be a Dependency");
1050+
return callback(
1051+
new WebpackError("Parameter 'dependency' must be a Dependency")
1052+
);
10521053
}
10531054
const Dep = /** @type {DepConstructor} */ (dependency.constructor);
10541055
const moduleFactory = this.dependencyFactories.get(Dep);
10551056
if (!moduleFactory) {
1056-
throw new Error(
1057-
`No dependency factory available for this dependency type: ${
1058-
dependency.constructor.name
1059-
}`
1057+
return callback(
1058+
new WebpackError(
1059+
`No dependency factory available for this dependency type: ${
1060+
dependency.constructor.name
1061+
}`
1062+
)
10601063
);
10611064
}
10621065

@@ -1076,7 +1079,7 @@ class Compilation {
10761079
this.factorizeQueue.stop();
10771080
return;
10781081
}
1079-
return callback();
1082+
callback();
10801083
}
10811084
);
10821085
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"events": "^3.0.0",
2020
"json-parse-better-errors": "^1.0.2",
2121
"json-stable-stringify": "^1.0.1",
22-
"loader-runner": "^2.3.0",
22+
"loader-runner": "hulkish/loader-runner#prefer-callback-errors",
2323
"loader-utils": "^1.1.0",
2424
"memory-fs": "~0.4.1",
2525
"micromatch": "^3.1.8",
@@ -61,6 +61,7 @@
6161
"lint-staged": "^8.0.4",
6262
"lodash": "^4.17.4",
6363
"prettier": "^1.14.3",
64+
"pretty-format": "24.0.0-alpha.1",
6465
"pug": "^2.0.3",
6566
"pug-loader": "^2.4.0",
6667
"raw-loader": "~0.5.0",

0 commit comments

Comments
 (0)