Skip to content

Commit 6a0db2c

Browse files
test: pin that a target with globalThis pays for no runtime module
Claude-Session: https://claude.ai/code/session_01US4dVfYJHHfNwvLNveDxAF
1 parent dc2f3dd commit 6a0db2c

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

‎test/configCases/parsing/top-level-this-global/entry-global-this.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ require("./common");
33
// built rather than written out, so the needle is not in the bundle it reads
44
const globalThisAccess = ["globalThis", "fromEntry"].join(".");
55
const runtimeGlobalAccess = ["__webpack_require__", "g", "fromEntry"].join(".");
6+
const runtimeGlobalDefinition = ["__webpack_require__", "g = "].join(".");
67

78
it("should spell the global object as globalThis", () => {
89
const source = require("fs").readFileSync(__filename, "utf8");
910

1011
expect(source).toContain(globalThisAccess);
1112
expect(source).not.toContain(runtimeGlobalAccess);
13+
// a target that has the binding pays for no runtime module either
14+
expect(source).not.toContain(runtimeGlobalDefinition);
1215
});
1316

1417
this.fromEntry = "entry";

‎test/configCases/parsing/top-level-this-global/entry-webpack-global.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ require("./common");
33
// built rather than written out, so the needle is not in the bundle it reads
44
const globalThisAccess = ["globalThis", "fromEntry"].join(".");
55
const runtimeGlobalAccess = ["__webpack_require__", "g", "fromEntry"].join(".");
6+
const runtimeGlobalDefinition = ["__webpack_require__", "g = "].join(".");
67

78
it("should spell the global object as __webpack_require__.g", () => {
89
const source = require("fs").readFileSync(__filename, "utf8");
910

1011
expect(source).toContain(runtimeGlobalAccess);
1112
expect(source).not.toContain(globalThisAccess);
13+
// and one that does not carries the polyfill
14+
expect(source).toContain(runtimeGlobalDefinition);
1215
});
1316

1417
this.fromEntry = "entry";

0 commit comments

Comments
 (0)