Skip to content

Commit 32f8b6b

Browse files
authored
Merge pull request webpack#5802 from webpack/bugfix/missing-harmony-crash
fix crashes when imported module fails compiling
2 parents dee0774 + 1381f67 commit 32f8b6b

6 files changed

Lines changed: 16 additions & 3 deletions

File tree

lib/dependencies/HarmonyExportImportedSpecifierDependency.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class HarmonyExportImportedSpecifierDependency extends NullDependency {
9696
// try to learn impossible exports from other star exports with provided exports
9797
for(const otherStarExport of this.otherStarExports) {
9898
const otherImportedModule = otherStarExport.importDependency.module;
99-
if(Array.isArray(otherImportedModule.providedExports)) {
99+
if(otherImportedModule && Array.isArray(otherImportedModule.providedExports)) {
100100
for(const exportName of otherImportedModule.providedExports)
101101
result.add(exportName);
102102
}
@@ -194,7 +194,7 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
194194
return "/* harmony reexport (module object) */ " + getReexportStatement(JSON.stringify(used), "");
195195
}
196196

197-
const hasProvidedExports = Array.isArray(importedModule.providedExports);
197+
const hasProvidedExports = importedModule && Array.isArray(importedModule.providedExports);
198198

199199
const activeFromOtherStarExports = dep._discoverActiveExportsFromOtherStartExports();
200200

lib/optimize/ConcatenatedModule.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ class ConcatenatedModule extends Module {
332332
dependency: dep
333333
});
334334
}
335-
} else {
335+
} else if(importedModule) {
336336
importedModule.providedExports.forEach(name => {
337337
if(dep.activeExports.has(name) || name === "default")
338338
return;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export var test = "test";
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = [
2+
[
3+
/Can't resolve '.\/missing'/
4+
]
5+
];
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
it("should not crash on importing missing modules", function() {
2+
(function() {
3+
require("./module");
4+
}).should.throw();
5+
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from "./missing";
2+
export * from "./a";

0 commit comments

Comments
 (0)