Skip to content

Commit 4c2f9e7

Browse files
committed
Merge branch 'master' into next
# Conflicts: # lib/dependencies/HarmonyExportImportedSpecifierDependency.js
2 parents 5abd696 + ce24e98 commit 4c2f9e7

10 files changed

Lines changed: 52 additions & 6 deletions

File tree

lib/ExternalModule.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class ExternalModule extends Module {
120120
updateHash(hash) {
121121
hash.update(this.type);
122122
hash.update(JSON.stringify(this.request));
123-
hash.update(JSON.stringify(this.optional));
123+
hash.update(JSON.stringify(Boolean(this.optional)));
124124
super.updateHash(hash);
125125
}
126126
}

lib/dependencies/HarmonyExportImportedSpecifierDependency.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
196196
// try to learn impossible exports from other star exports with provided exports
197197
for(const otherStarExport of this.otherStarExports) {
198198
const otherImportedModule = otherStarExport.module;
199-
if(Array.isArray(otherImportedModule.providedExports)) {
199+
if(otherImportedModule && Array.isArray(otherImportedModule.providedExports)) {
200200
for(const exportName of otherImportedModule.providedExports)
201201
result.add(exportName);
202202
}
@@ -272,13 +272,16 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
272272
if(!dep.name) {
273273
const importedModule = dep.module;
274274

275+
const activeFromOtherStarExports = dep._discoverActiveExportsFromOtherStartExports();
276+
275277
if(Array.isArray(dep.originModule.usedExports)) {
276278
// we know which exports are used
277279

278280
const unused = dep.originModule.usedExports.every(function(id) {
279281
if(id === "default") return true;
280282
if(dep.activeExports.has(id)) return true;
281283
if(importedModule.isProvided(id) === false) return true;
284+
if(activeFromOtherStarExports.has(id)) return true;
282285
return false;
283286
});
284287
if(unused) return NaN;
@@ -289,6 +292,7 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
289292
const unused = importedModule.providedExports.every(function(id) {
290293
if(id === "default") return true;
291294
if(dep.activeExports.has(id)) return true;
295+
if(activeFromOtherStarExports.has(id)) return true;
292296
return false;
293297
});
294298
if(unused) return NaN;

lib/optimize/ConcatenatedModule.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ class ConcatenatedModule extends Module {
334334
dependency: dep
335335
});
336336
}
337-
} else {
337+
} else if(importedModule) {
338338
importedModule.providedExports.forEach(name => {
339339
if(dep.activeExports.has(name) || name === "default")
340340
return;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webpack",
3-
"version": "3.6.0",
3+
"version": "3.7.1",
44
"author": "Tobias Koppers @sokra",
55
"description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
66
"dependencies": {

test/ExternalModule.test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,4 +340,32 @@ module.exports = some/request;`;
340340
hashedText.should.containEql("12345678");
341341
});
342342
});
343+
344+
describe("#updateHash without optional", function() {
345+
let hashedText;
346+
let hash;
347+
beforeEach(function() {
348+
hashedText = "";
349+
hash = {
350+
update: (text) => {
351+
hashedText += text;
352+
}
353+
};
354+
// Note no set of `externalModule.optional`, which crashed externals in 3.7.0
355+
externalModule.id = 12345678;
356+
externalModule.updateHash(hash);
357+
});
358+
it("updates hash with request", function() {
359+
hashedText.should.containEql("some/request");
360+
});
361+
it("updates hash with type", function() {
362+
hashedText.should.containEql("some-type");
363+
});
364+
it("updates hash with optional flag", function() {
365+
hashedText.should.containEql("false");
366+
});
367+
it("updates hash with module id", function() {
368+
hashedText.should.containEql("12345678");
369+
});
370+
});
343371
});

test/Stats.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ const Stats = require("../lib/Stats");
1717

1818
describe("Stats", () => {
1919
tests.forEach(testName => {
20-
it("should print correct stats for " + testName, (done) => {
20+
it("should print correct stats for " + testName, function(done) {
21+
this.timeout(10000);
2122
let options = {
2223
entry: "./index",
2324
output: {
@@ -104,7 +105,7 @@ describe("Stats", () => {
104105
actual.should.be.eql(expected);
105106
done();
106107
});
107-
}, 10000);
108+
});
108109
});
109110
describe("Error Handling", () => {
110111
describe("does have", () => {
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)