Skip to content

Commit 9540704

Browse files
committed
fix DllPlugin flagging
1 parent ae2919d commit 9540704

5 files changed

Lines changed: 23 additions & 8 deletions

File tree

lib/DllPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class DllPlugin {
3131
return true;
3232
});
3333
compiler.apply(new LibManifestPlugin(this.options));
34-
compiler.apply(new FlagInitialModulesAsUsedPlugin());
34+
compiler.apply(new FlagInitialModulesAsUsedPlugin("DllPlugin"));
3535
}
3636
}
3737

lib/FlagInitialModulesAsUsedPlugin.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
"use strict";
66

77
class FlagInitialModulesAsUsedPlugin {
8+
constructor(explaination) {
9+
this.explaination = explaination;
10+
}
11+
812
apply(compiler) {
913
compiler.plugin("compilation", (compilation) => {
1014
compilation.plugin("after-optimize-chunks", (chunks) => {
@@ -15,6 +19,7 @@ class FlagInitialModulesAsUsedPlugin {
1519
chunk.forEachModule((module) => {
1620
module.used = true;
1721
module.usedExports = true;
22+
module.addReason(null, null, this.explaination);
1823
});
1924
});
2025
});

lib/Module.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class Module extends DependenciesBlock {
143143
}
144144

145145
get optional() {
146-
return this.reasons.length > 0 && this.reasons.every(r => r.dependency.optional);
146+
return this.reasons.length > 0 && this.reasons.every(r => r.dependency && r.dependency.optional);
147147
}
148148

149149
forEachChunk(fn) {
@@ -180,8 +180,8 @@ class Module extends DependenciesBlock {
180180
}
181181
}
182182

183-
addReason(module, dependency) {
184-
this.reasons.push(new ModuleReason(module, dependency));
183+
addReason(module, dependency, explaination) {
184+
this.reasons.push(new ModuleReason(module, dependency, explaination));
185185
}
186186

187187
removeReason(module, dependency) {

lib/ModuleReason.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
const util = require("util");
88

99
class ModuleReason {
10-
constructor(module, dependency) {
10+
constructor(module, dependency, explaination) {
1111
this.module = module;
1212
this.dependency = dependency;
13+
this.explaination = explaination;
1314
this._chunks = null;
1415
}
1516

lib/optimize/ModuleConcatenationPlugin.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,22 @@ class ModuleConcatenationPlugin {
8484
}
8585

8686
// Module must only be used by Harmony Imports
87-
const nonHarmonyReasons = module.reasons.filter(reason => !(reason.dependency instanceof HarmonyImportDependency));
87+
const nonHarmonyReasons = module.reasons.filter(reason => !reason.dependency || !(reason.dependency instanceof HarmonyImportDependency));
8888
if(nonHarmonyReasons.length > 0) {
89-
const importingModules = new Set(nonHarmonyReasons.map(r => r.module));
89+
const importingModules = new Set(nonHarmonyReasons.map(r => r.module).filter(Boolean));
90+
const importingExplainations = new Set(nonHarmonyReasons.map(r => r.explaination).filter(Boolean));
9091
const importingModuleTypes = new Map(Array.from(importingModules).map(m => [m, new Set(nonHarmonyReasons.filter(r => r.module === m).map(r => r.dependency.type).sort())]));
9192
setBailoutReason(module, (requestShortener) => {
9293
const names = Array.from(importingModules).map(m => `${m.readableIdentifier(requestShortener)} (referenced with ${Array.from(importingModuleTypes.get(m)).join(", ")})`).sort();
93-
return `Module is referenced from these modules with unsupported syntax: ${names.join(", ")}`;
94+
const explainations = Array.from(importingExplainations).sort();
95+
if(names.length > 0 && explainations.length === 0)
96+
return `Module is referenced from these modules with unsupported syntax: ${names.join(", ")}`;
97+
else if(names.length === 0 && explainations.length > 0)
98+
return `Module is referenced by: ${explainations.join(", ")}`;
99+
else if(names.length > 0 && explainations.length > 0)
100+
return `Module is referenced from these modules with unsupported syntax: ${names.join(", ")} and by: ${explainations.join(", ")}`;
101+
else
102+
return "Module is referenced in a unsupported way";
94103
});
95104
continue;
96105
}

0 commit comments

Comments
 (0)