Merge pull request #5807 from STRML/fix/externalModule

Fix #5806, TypeError on ExternalModule hash.update
This commit is contained in:
Tobias Koppers 2017-10-11 21:37:41 +02:00 committed by GitHub
commit 15fe297fb1
2 changed files with 29 additions and 1 deletions

View File

@ -120,7 +120,7 @@ class ExternalModule extends Module {
updateHash(hash) {
hash.update(this.type);
hash.update(JSON.stringify(this.request));
hash.update(JSON.stringify(this.optional));
hash.update(JSON.stringify(Boolean(this.optional)));
super.updateHash(hash);
}
}

View File

@ -340,4 +340,32 @@ module.exports = some/request;`;
hashedText.should.containEql("12345678");
});
});
describe("#updateHash without optional", function() {
let hashedText;
let hash;
beforeEach(function() {
hashedText = "";
hash = {
update: (text) => {
hashedText += text;
}
};
// Note no set of `externalModule.optional`, which crashed externals in 3.7.0
externalModule.id = 12345678;
externalModule.updateHash(hash);
});
it("updates hash with request", function() {
hashedText.should.containEql("some/request");
});
it("updates hash with type", function() {
hashedText.should.containEql("some-type");
});
it("updates hash with optional flag", function() {
hashedText.should.containEql("false");
});
it("updates hash with module id", function() {
hashedText.should.containEql("12345678");
});
});
});