diff --git a/lib/ExternalModule.js b/lib/ExternalModule.js index d9d6fbcd4..de1e9db9c 100644 --- a/lib/ExternalModule.js +++ b/lib/ExternalModule.js @@ -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); } } diff --git a/test/ExternalModule.test.js b/test/ExternalModule.test.js index 6fd56c6a2..bd7e4bf75 100644 --- a/test/ExternalModule.test.js +++ b/test/ExternalModule.test.js @@ -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"); + }); + }); });