Skip to content

Commit 4c4121b

Browse files
committed
fix test and lint issues
1 parent 2ff9b53 commit 4c4121b

4 files changed

Lines changed: 26 additions & 18 deletions

File tree

‎lib/Compilation.js‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ class Compilation extends Tapable {
212212
const resourceIdent = dep.getResourceIdentifier();
213213
if(resourceIdent) {
214214
const factory = this.dependencyFactories.get(dep.constructor);
215+
if(factory === undefined)
216+
throw new Error(`No module factory available for dependency type: ${dep.constructor.name}`);
215217
let innerMap = dependencies.get(factory);
216218
if(innerMap === undefined)
217219
dependencies.set(factory, innerMap = new Map());
@@ -234,7 +236,11 @@ class Compilation extends Tapable {
234236
}
235237
};
236238

237-
addDependenciesBlock(module);
239+
try {
240+
addDependenciesBlock(module);
241+
} catch(e) {
242+
callback(e);
243+
}
238244

239245
const sortedDependencies = [];
240246

‎lib/dependencies/ContextDependency.js‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66
const Dependency = require("../Dependency");
77
const CriticalDependencyWarning = require("./CriticalDependencyWarning");
88

9-
const equalRegExp = (a, b) => {
10-
if(a === b) return true;
11-
if(typeof a !== "object" || typeof b !== "object") return false;
12-
return a + "" === b + "";
13-
};
14-
159
const regExpToString = r => r ? r + "" : "";
1610

1711
class ContextDependency extends Dependency {

‎lib/dependencies/LoaderPlugin.js‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@ class LoaderPlugin {
1919
loaderContext.loadModule = (request, callback) => {
2020
const dep = new LoaderDependency(request);
2121
dep.loc = request;
22-
compilation.addModuleDependencies(module, [
23-
[dep]
24-
], true, "lm", false, err => {
22+
const factory = compilation.dependencyFactories.get(dep.constructor);
23+
if(factory === undefined)
24+
return callback(new Error(`No module factory available for dependency type: ${dep.constructor.name}`));
25+
compilation.addModuleDependencies(module, [{
26+
factory,
27+
dependencies: [dep]
28+
}], true, "lm", false, err => {
2529
if(err) return callback(err);
2630

2731
if(!dep.module) return callback(new Error("Cannot load the module"));

‎lib/util/StackedSetMap.js‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class StackedSetMap {
6666
}
6767

6868
_compress() {
69+
if(this.stack.length === 1) return;
6970
this.map = new Map();
7071
for(const data of this.stack) {
7172
for(const pair of data) {
@@ -78,24 +79,27 @@ class StackedSetMap {
7879
this.stack = [this.map];
7980
}
8081

81-
asSet() {
82+
asArray() {
8283
this._compress();
83-
return new Set(Array.from(this.map.entries()).map(pair => pair[0]));
84+
return Array.from(this.map.entries(), pair => pair[0]);
8485
}
8586

86-
asArray() {
87+
asSet() {
88+
return new Set(this.asArray());
89+
}
90+
91+
asPairArray() {
8792
this._compress();
88-
return Array.from(this.map.entries()).map(pair => pair[0]);
93+
return Array.from(this.map.entries(), pair => pair[1] === UNDEFINED_MARKER ? [pair[0], undefined] : pair);
8994
}
9095

9196
asMap() {
92-
this._compress();
93-
return new Map(this.map.entries());
97+
return new Map(this.asPairArray());
9498
}
9599

96-
asPairArray() {
100+
get size() {
97101
this._compress();
98-
return Array.from(this.map.entries());
102+
return this.map.size;
99103
}
100104

101105
createChild() {

0 commit comments

Comments
 (0)