From 058a5f46590c05872d6d1c81bd59b7609180fd9b Mon Sep 17 00:00:00 2001 From: Marcus Armstrong Date: Fri, 13 Apr 2018 16:40:16 -0400 Subject: [PATCH 1/3] Correct ExternalModule's global option (#6933) --- lib/ExternalModule.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ExternalModule.js b/lib/ExternalModule.js index 98d1560b883..8707f4f1f61 100644 --- a/lib/ExternalModule.js +++ b/lib/ExternalModule.js @@ -113,8 +113,8 @@ class ExternalModule extends Module { ); case "global": return this.getSourceForGlobalVariableExternal( - runtime.outputOptions.globalObject, - this.externalType + request, + runtime.outputOptions.globalObject ); case "commonjs": case "commonjs2": From 5853ec5caed54a496bdd030c127134f1a089ce69 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 20 Jun 2018 12:34:45 +0200 Subject: [PATCH 2/3] add test case --- test/configCases/externals/global/index.js | 10 ++++++++++ test/configCases/externals/global/webpack.config.js | 5 +++++ 2 files changed, 15 insertions(+) create mode 100644 test/configCases/externals/global/index.js create mode 100644 test/configCases/externals/global/webpack.config.js diff --git a/test/configCases/externals/global/index.js b/test/configCases/externals/global/index.js new file mode 100644 index 00000000000..f76fe086797 --- /dev/null +++ b/test/configCases/externals/global/index.js @@ -0,0 +1,10 @@ +afterEach(() => { + delete global.EXTERNAL_TEST_GLOBAL; +}); + +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); +}); diff --git a/test/configCases/externals/global/webpack.config.js b/test/configCases/externals/global/webpack.config.js new file mode 100644 index 00000000000..5e9889bf360 --- /dev/null +++ b/test/configCases/externals/global/webpack.config.js @@ -0,0 +1,5 @@ +module.exports = { + externals: { + external: "global EXTERNAL_TEST_GLOBAL" + } +}; From 15b6f8bb7ff6e9f38e2089f363f4e37131af13f9 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 17 Oct 2018 16:17:23 +0200 Subject: [PATCH 3/3] make afterEach async --- test/configCases/externals/global/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/configCases/externals/global/index.js b/test/configCases/externals/global/index.js index f76fe086797..821f2376eb2 100644 --- a/test/configCases/externals/global/index.js +++ b/test/configCases/externals/global/index.js @@ -1,5 +1,6 @@ -afterEach(() => { +afterEach(done => { delete global.EXTERNAL_TEST_GLOBAL; + done(); }); it("should move externals in chunks into entry chunk", function() {