Skip to content

Commit 8cce571

Browse files
authored
fix(runtime): fixed an issue where script failed to load properly when static resources were set to cross-domain response headers due to the default setting of script crossorigin to anonymous (this issue appeared in next.js) (#2706)
1 parent 082b56a commit 8cce571

File tree

6 files changed

+22781
-19265
lines changed

6 files changed

+22781
-19265
lines changed

.changeset/thick-pianos-perform.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@module-federation/runtime': patch
3+
'@module-federation/sdk': patch
4+
---
5+
6+
fix(runtime): Fixed an issue where script failed to load properly when static resources were set to cross-domain response headers due to the default setting of script crossorigin to anonymous (this issue appeared in next.js)
7+

packages/runtime/__tests__/__snapshots__/preload-remote.spec.ts.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ exports[`preload-remote inBrowser > 1 preload with default config 1`] = `
2121
],
2222
"scripts": [
2323
{
24-
"crossorigin": "anonymous",
24+
"crossorigin": "",
2525
"src": "http://localhost:1111/resources/preload/preload-resource/federation-remote-entry.js",
2626
},
2727
{
28-
"crossorigin": "anonymous",
28+
"crossorigin": "",
2929
"src": "http://localhost:1111/resources/preload/preload-resource/sub1-button/federation-remote-entry.js",
3030
},
3131
],
@@ -78,11 +78,11 @@ exports[`preload-remote inBrowser > 2 preload with all config 1`] = `
7878
],
7979
"scripts": [
8080
{
81-
"crossorigin": "anonymous",
81+
"crossorigin": "",
8282
"src": "http://localhost:1111/resources/preload/preload-resource/sub2/federation-remote-entry.js",
8383
},
8484
{
85-
"crossorigin": "anonymous",
85+
"crossorigin": "",
8686
"src": "http://localhost:1111/resources/preload/preload-resource/sub2-button/federation-remote-entry.js",
8787
},
8888
],
@@ -100,7 +100,7 @@ exports[`preload-remote inBrowser > 3 preload with expose config 1`] = `
100100
],
101101
"scripts": [
102102
{
103-
"crossorigin": "anonymous",
103+
"crossorigin": "",
104104
"src": "http://localhost:1111/resources/preload/preload-resource/sub3/federation-remote-entry.js",
105105
},
106106
],
@@ -118,7 +118,7 @@ exports[`preload-remote inBrowser > 3 preload with expose config 2`] = `
118118
],
119119
"scripts": [
120120
{
121-
"crossorigin": "anonymous",
121+
"crossorigin": "",
122122
"src": "http://localhost:1111/resources/preload/preload-resource/sub3/federation-remote-entry.js",
123123
},
124124
],

packages/runtime/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
"parallel": false,
7777
"commands": [
7878
{
79-
"command": "vitest run -c packages/runtime/vitest.config.ts",
79+
"command": "vitest run -u -c packages/runtime/vitest.config.ts",
8080
"forwardAllArgs": false
8181
}
8282
]

packages/runtime/src/utils/preload.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ export function preloadAssets(
209209
url: jsUrl,
210210
cb: () => {},
211211
attrs: {
212-
crossorigin: 'anonymous',
213212
fetchpriority: 'high',
214213
},
215214
createScriptHook: (url: string) => {

packages/sdk/src/dom.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ export function loadScript(
217217
url,
218218
cb: resolve,
219219
attrs: {
220-
crossorigin: 'anonymous',
221220
fetchpriority: 'high',
222221
...attrs,
223222
},

0 commit comments

Comments
 (0)