@@ -29,7 +29,7 @@ declare const __webpack_share_scopes__: { default: Scope };
29
29
type ContainerMap = { [ key : string ] : Container } ;
30
30
31
31
const containerMap : ContainerMap = { } ;
32
- const remoteMap = { } ;
32
+ const remoteMap : { [ key : string ] : boolean } = { } ;
33
33
34
34
let isDefaultScopeInitialized = false ;
35
35
@@ -70,6 +70,7 @@ export type LoadRemoteEntryScriptOptions = {
70
70
type ?: 'script' ;
71
71
remoteEntry : string ;
72
72
remoteName : string ;
73
+ nonce ?: string ;
73
74
} ;
74
75
75
76
export type LoadRemoteEntryEsmOptions = {
@@ -86,14 +87,19 @@ export async function loadRemoteEntry(
86
87
) : Promise < void > ;
87
88
export async function loadRemoteEntry (
88
89
remoteEntryOrOptions : string | LoadRemoteEntryOptions ,
89
- remoteName ?: string
90
+ remoteName ?: string ,
91
+ nonce ?: string
90
92
) : Promise < void > {
91
93
if ( typeof remoteEntryOrOptions === 'string' ) {
92
94
const remoteEntry = remoteEntryOrOptions ;
93
- return await loadRemoteScriptEntry ( remoteEntry , remoteName ) ;
95
+ return await loadRemoteScriptEntry ( remoteEntry , remoteName , nonce ) ;
94
96
} else if ( remoteEntryOrOptions . type === 'script' ) {
95
97
const options = remoteEntryOrOptions ;
96
- return await loadRemoteScriptEntry ( options . remoteEntry , options . remoteName ) ;
98
+ return await loadRemoteScriptEntry (
99
+ options . remoteEntry ,
100
+ options . remoteName ,
101
+ options . nonce
102
+ ) ;
97
103
} else if ( remoteEntryOrOptions . type === 'module' ) {
98
104
const options = remoteEntryOrOptions ;
99
105
await loadRemoteModuleEntry ( options . remoteEntry ) ;
@@ -114,7 +120,8 @@ async function loadRemoteModuleEntry(remoteEntry: string): Promise<void> {
114
120
115
121
async function loadRemoteScriptEntry (
116
122
remoteEntry : string ,
117
- remoteName : string
123
+ remoteName : string ,
124
+ nonce ?: string
118
125
) : Promise < void > {
119
126
return new Promise < void > ( ( resolve , reject ) => {
120
127
// Is remoteEntry already loaded?
@@ -125,6 +132,9 @@ async function loadRemoteScriptEntry(
125
132
126
133
const script = document . createElement ( 'script' ) ;
127
134
script . src = remoteEntry ;
135
+ if ( nonce ) {
136
+ script . setAttribute ( 'nonce' , nonce ) ;
137
+ }
128
138
129
139
script . onerror = reject ;
130
140
@@ -149,6 +159,7 @@ export type LoadRemoteModuleScriptOptions = {
149
159
remoteEntry ?: string ;
150
160
remoteName : string ;
151
161
exposedModule : string ;
162
+ nonce ?: string ;
152
163
} ;
153
164
154
165
export type LoadRemoteModuleEsmOptions = {
@@ -218,6 +229,7 @@ export async function loadRemoteModule<T = any>(
218
229
type : 'script' ,
219
230
remoteEntry : options . remoteEntry ,
220
231
remoteName : options . remoteName ,
232
+ nonce : options . nonce ,
221
233
} ;
222
234
key = options . remoteName ;
223
235
} else if ( options . type === 'module' ) {
0 commit comments