Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct ExternalModule's global option (#6933) #7038

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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"
}
};