-
-
Notifications
You must be signed in to change notification settings - Fork 587
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: trusted type should add module runtime requirements (#8617)
- Loading branch information
1 parent
0bf7360
commit 4cedd61
Showing
7 changed files
with
81 additions
and
14 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
19 changes: 19 additions & 0 deletions
19
...ges/rspack-test-tools/tests/configCases/trusted-types/module-runtime-requirement/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,19 @@ | ||
const fs = __non_webpack_require__("fs"); | ||
const path = __non_webpack_require__("path"); | ||
|
||
|
||
function createWorker() { | ||
new Worker(new URL("./worker.js", import.meta.url), { | ||
type: "module", | ||
name: "test-worker" | ||
}); | ||
} | ||
|
||
createWorker; | ||
|
||
it("should generate correct new Worker statement", async () => { | ||
const content = fs.readFileSync(path.resolve(path.dirname(__filename), './test-worker.js'), "utf-8"); | ||
expect(content).toContain(`this is worker`); | ||
expect(content).toContain(`(function (__unused_webpack_module, __unused_webpack_exports, __webpack_require__)`); | ||
expect(content).toContain(`eval(__webpack_require__.ts(`); | ||
}); |
13 changes: 13 additions & 0 deletions
13
...ck-test-tools/tests/configCases/trusted-types/module-runtime-requirement/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,13 @@ | ||
module.exports = { | ||
output: { | ||
filename: "[name].js", | ||
chunkFilename: "[name].js", | ||
trustedTypes: true | ||
}, | ||
node: { | ||
__dirname: false, | ||
__filename: false | ||
}, | ||
devtool: "eval-source-map", | ||
target: "web" | ||
}; |
5 changes: 5 additions & 0 deletions
5
...pack-test-tools/tests/configCases/trusted-types/module-runtime-requirement/test.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,5 @@ | ||
module.exports = { | ||
findBundle: function (i, options) { | ||
return ["main.js"]; | ||
} | ||
}; |
1 change: 1 addition & 0 deletions
1
...es/rspack-test-tools/tests/configCases/trusted-types/module-runtime-requirement/worker.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 @@ | ||
"this is worker"; |
4cedd61
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Ran ecosystem CI: Open
4cedd61
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Benchmark detail: Open