-
-
Notifications
You must be signed in to change notification settings - Fork 610
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: should not eval exports in harmony (#6883)
- Loading branch information
Showing
11 changed files
with
100 additions
and
68 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
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
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
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
6 changes: 3 additions & 3 deletions
6
packages/rspack-test-tools/tests/configCases/parsing/eval-cjs-typeof/index.js
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
const fs = require("fs"); | ||
|
||
it("should compile", () => { | ||
it("should compile", async () => { | ||
if (typeof exports !== "object" || typeof module !== "object") { | ||
throw new Error("wrong") | ||
} | ||
const file = fs.promises.readFile(__filename); | ||
expect(file).not.toContain("typeof") | ||
const file = await fs.promises.readFile(__filename, 'utf-8'); | ||
expect(file).not.toContain(["type", "of"].join("")) | ||
}); |
8 changes: 8 additions & 0 deletions
8
...es/rspack-test-tools/tests/configCases/parsing/eval-exports-in-detection-harmony/index.js
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,8 @@ | ||
import fs from "fs"; // import make this module a detection harmony | ||
|
||
it("should compile", async () => { | ||
const a = typeof exports === "object"; | ||
const file = await fs.promises.readFile(__filename, 'utf-8'); | ||
expect(file).not.toContain(["const", "a", "=", "true"].join(" ")) | ||
expect(file).toContain(["const", "a", "=", "typeof", "exports", "===", "\"object\""].join(" ")) | ||
}); |
6 changes: 6 additions & 0 deletions
6
...k-test-tools/tests/configCases/parsing/eval-exports-in-detection-harmony/rspack.config.js
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,6 @@ | ||
/** @type {import("@rspack/core").Configuration} */ | ||
module.exports = { | ||
node: { | ||
__filename: false, | ||
} | ||
}; |