Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11759 from webpack/fix-external-this-concatenation
Make external modules of type 'this' work with module concatenation
- Loading branch information
Showing
3 changed files
with
26 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
afterEach(done => { | ||
(function() { delete this.EXTERNAL_TEST_GLOBAL; })(); | ||
done(); | ||
}); | ||
|
||
it("should import an external value assigned to global this", function() { | ||
(function() { this.EXTERNAL_TEST_GLOBAL = 42; })(); | ||
// eslint-disable-next-line node/no-missing-require | ||
const result = require("external"); | ||
expect(result).toBe(42); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** @type {import("../../../../").Configuration} */ | ||
module.exports = { | ||
optimization: { | ||
concatenateModules: true | ||
}, | ||
externals: { | ||
external: "this EXTERNAL_TEST_GLOBAL" | ||
} | ||
}; |