-
-
Notifications
You must be signed in to change notification settings - Fork 603
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for output.crossOriginLoading config (#2632)
* feat: add basic support for output.crossOriginLoading * feat: allow crossOriginLoading to be false value * chore: update CrossOriginLoading::Disable * test: add e2e test for crossOriginLoading * chore: update pnpm-lock.yaml * Update crates/rspack_plugin_runtime/src/runtime_module/css_loading.rs * Update crates/rspack_plugin_runtime/src/runtime_module/load_script.rs * Update crates/rspack_plugin_runtime/src/runtime_module/css_loading.rs * Update crates/rspack_plugin_runtime/src/runtime_module/load_script.rs --------- Co-authored-by: underfin <likui6666666@gmail.com>
- Loading branch information
1 parent
a9e1adf
commit d007971
Showing
26 changed files
with
239 additions
and
12 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
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
4 changes: 4 additions & 0 deletions
4
packages/playground/fixtures/cross-origin-loading/package.json
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,4 @@ | ||
{ | ||
"name": "@rspack-test/cross-origin-loading", | ||
"private": true | ||
} |
24 changes: 24 additions & 0 deletions
24
packages/playground/fixtures/cross-origin-loading/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,24 @@ | ||
/** @type { import('@rspack/core').RspackOptions } */ | ||
|
||
module.exports = { | ||
context: __dirname, | ||
mode: "development", | ||
entry: "./src/index.js", | ||
stats: "none", | ||
builtins: { | ||
html: [ | ||
{ | ||
template: "./src/index.html" | ||
} | ||
], | ||
define: { | ||
"process.env.NODE_ENV": JSON.stringify("development") | ||
} | ||
}, | ||
output: { | ||
crossOriginLoading: "anonymous" | ||
}, | ||
devServer: { | ||
port: 3000 | ||
} | ||
}; |
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 @@ | ||
export default "foo"; |
7 changes: 7 additions & 0 deletions
7
packages/playground/fixtures/cross-origin-loading/src/index.html
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,7 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> </head> | ||
<body> | ||
<div id="root"></div> | ||
</body> | ||
</html> |
7 changes: 7 additions & 0 deletions
7
packages/playground/fixtures/cross-origin-loading/src/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,7 @@ | ||
// Set the public path of async chunk to a cross-origin URL | ||
__webpack_public_path__ = "https://cdn.example.com/"; | ||
|
||
// Avoid removing script tag | ||
Node.prototype.removeChild = () => {}; | ||
|
||
import("./foo.js"); |
12 changes: 12 additions & 0 deletions
12
packages/playground/fixtures/cross-origin-loading/test/index.test.ts
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,12 @@ | ||
import { wait } from "../../utils"; | ||
|
||
test("should set crossOrigin to anonymous for script tag correctly", async () => { | ||
await wait(50); | ||
const scripts = await page.$$("script"); | ||
|
||
const crossOrigins = await Promise.all( | ||
scripts.map(script => script.getAttribute("crossorigin")) | ||
); | ||
|
||
expect(crossOrigins).toEqual(["anonymous", null]); | ||
}); |
File renamed without changes.
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
Oops, something went wrong.