@@ -29,7 +29,7 @@ declare const __webpack_share_scopes__: { default: Scope };
2929type ContainerMap = { [ key : string ] : Container } ;
3030
3131const containerMap : ContainerMap = { } ;
32- const remoteMap = { } ;
32+ const remoteMap : { [ key : string ] : boolean } = { } ;
3333
3434let isDefaultScopeInitialized = false ;
3535
@@ -70,6 +70,7 @@ export type LoadRemoteEntryScriptOptions = {
7070 type ?: 'script' ;
7171 remoteEntry : string ;
7272 remoteName : string ;
73+ nonce ?: string ;
7374} ;
7475
7576export type LoadRemoteEntryEsmOptions = {
@@ -87,13 +88,18 @@ export async function loadRemoteEntry(
8788export async function loadRemoteEntry (
8889 remoteEntryOrOptions : string | LoadRemoteEntryOptions ,
8990 remoteName ?: string ,
91+ nonce ?: string
9092) : Promise < void > {
9193 if ( typeof remoteEntryOrOptions === 'string' ) {
9294 const remoteEntry = remoteEntryOrOptions ;
93- return await loadRemoteScriptEntry ( remoteEntry , remoteName ) ;
95+ return await loadRemoteScriptEntry ( remoteEntry , remoteName , nonce ) ;
9496 } else if ( remoteEntryOrOptions . type === 'script' ) {
9597 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+ ) ;
97103 } else if ( remoteEntryOrOptions . type === 'module' ) {
98104 const options = remoteEntryOrOptions ;
99105 await loadRemoteModuleEntry ( options . remoteEntry ) ;
@@ -115,6 +121,7 @@ async function loadRemoteModuleEntry(remoteEntry: string): Promise<void> {
115121async function loadRemoteScriptEntry (
116122 remoteEntry : string ,
117123 remoteName : string ,
124+ nonce ?: string
118125) : Promise < void > {
119126 return new Promise < void > ( ( resolve , reject ) => {
120127 // Is remoteEntry already loaded?
@@ -125,6 +132,9 @@ async function loadRemoteScriptEntry(
125132
126133 const script = document . createElement ( 'script' ) ;
127134 script . src = remoteEntry ;
135+ if ( nonce ) {
136+ script . setAttribute ( 'nonce' , nonce ) ;
137+ }
128138
129139 script . onerror = reject ;
130140
@@ -149,6 +159,7 @@ export type LoadRemoteModuleScriptOptions = {
149159 remoteEntry ?: string ;
150160 remoteName : string ;
151161 exposedModule : string ;
162+ nonce ?: string ;
152163} ;
153164
154165export type LoadRemoteModuleEsmOptions = {
@@ -218,6 +229,7 @@ export async function loadRemoteModule<T = any>(
218229 type : 'script' ,
219230 remoteEntry : options . remoteEntry ,
220231 remoteName : options . remoteName ,
232+ nonce : options . nonce ,
221233 } ;
222234 key = options . remoteName ;
223235 } else if ( options . type === 'module' ) {
0 commit comments