Skip to content

Commit d26d7e6

Browse files
fix(runtime): ensured attributes are forwarded to createScript hook (#2799)
Co-authored-by: Zack Jackson <[email protected]>
1 parent 67ea678 commit d26d7e6

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

.changeset/good-shirts-cover.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/runtime': patch
3+
---
4+
5+
Ensured createScript runtime hook always receives `attrs`

packages/runtime/src/utils/preload.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ export function preloadAssets(
8282
getRemoteEntry({
8383
remoteInfo: moduleInfo,
8484
remoteEntryExports: module.remoteEntryExports,
85-
createScriptHook: (url: string) => {
85+
createScriptHook: (url: string, attrs: any) => {
8686
const res = host.loaderHook.lifecycle.createScript.emit({
8787
url,
88+
attrs,
8889
});
8990
if (!res) return;
9091

@@ -108,9 +109,10 @@ export function preloadAssets(
108109
getRemoteEntry({
109110
remoteInfo: moduleInfo,
110111
remoteEntryExports: undefined,
111-
createScriptHook: (url: string) => {
112+
createScriptHook: (url: string, attrs: any) => {
112113
const res = host.loaderHook.lifecycle.createScript.emit({
113114
url,
115+
attrs,
114116
});
115117
if (!res) return;
116118

@@ -212,9 +214,10 @@ export function preloadAssets(
212214
fetchpriority: 'high',
213215
type: remoteInfo?.type === 'module' ? 'module' : 'text/javascript',
214216
},
215-
createScriptHook: (url: string) => {
217+
createScriptHook: (url: string, attrs: any) => {
216218
const res = host.loaderHook.lifecycle.createScript.emit({
217219
url,
220+
attrs,
218221
});
219222
if (res instanceof HTMLScriptElement) {
220223
return res;

0 commit comments

Comments
 (0)