Skip to content

Commit

Permalink
Merge pull request #7038 from marcusdarmstrong/marcusdarmstrong-exter…
Browse files Browse the repository at this point in the history
…nal-module-fix

Correct ExternalModule's global option (#6933)
  • Loading branch information
sokra committed Oct 17, 2018
2 parents 2228daf + 15b6f8b commit 0fb6c60
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/ExternalModule.js
Expand Up @@ -127,8 +127,8 @@ class ExternalModule extends Module {
);
case "global":
return this.getSourceForGlobalVariableExternal(
runtime.outputOptions.globalObject,
this.externalType
request,
runtime.outputOptions.globalObject
);
case "commonjs":
case "commonjs2":
Expand Down
11 changes: 11 additions & 0 deletions test/configCases/externals/global/index.js
@@ -0,0 +1,11 @@
afterEach(done => {
delete global.EXTERNAL_TEST_GLOBAL;
done();
});

it("should move externals in chunks into entry chunk", function() {
global.EXTERNAL_TEST_GLOBAL = 42;
// eslint-disable-next-line node/no-missing-require
const result = require("external");
expect(result).toBe(42);
});
5 changes: 5 additions & 0 deletions test/configCases/externals/global/webpack.config.js
@@ -0,0 +1,5 @@
module.exports = {
externals: {
external: "global EXTERNAL_TEST_GLOBAL"
}
};

0 comments on commit 0fb6c60

Please sign in to comment.