Skip to content

Commit 0fb6c60

Browse files
authored
Merge pull request webpack#7038 from marcusdarmstrong/marcusdarmstrong-external-module-fix
Correct ExternalModule's global option (webpack#6933)
2 parents 2228daf + 15b6f8b commit 0fb6c60

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

lib/ExternalModule.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ class ExternalModule extends Module {
127127
);
128128
case "global":
129129
return this.getSourceForGlobalVariableExternal(
130-
runtime.outputOptions.globalObject,
131-
this.externalType
130+
request,
131+
runtime.outputOptions.globalObject
132132
);
133133
case "commonjs":
134134
case "commonjs2":
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
afterEach(done => {
2+
delete global.EXTERNAL_TEST_GLOBAL;
3+
done();
4+
});
5+
6+
it("should move externals in chunks into entry chunk", function() {
7+
global.EXTERNAL_TEST_GLOBAL = 42;
8+
// eslint-disable-next-line node/no-missing-require
9+
const result = require("external");
10+
expect(result).toBe(42);
11+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
externals: {
3+
external: "global EXTERNAL_TEST_GLOBAL"
4+
}
5+
};

0 commit comments

Comments
 (0)