@module-federation/webpack-bundler-runtime 0.19.1 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const FEDERATION_SUPPORTED_TYPES = [
4
- 'script'
5
- ];
3
+ const FEDERATION_SUPPORTED_TYPES = ['script'];
6
4
 
7
5
  exports.FEDERATION_SUPPORTED_TYPES = FEDERATION_SUPPORTED_TYPES;
8
6
  //# sourceMappingURL=constant.cjs.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"constant.cjs.cjs","sources":["../../src/constant.ts"],"sourcesContent":[null],"names":["FEDERATION_SUPPORTED_TYPES"],"mappings":";;MAAaA,0BAA6B,GAAA;AAAC,IAAA;AAAS;;;;"}
1
+ {"version":3,"file":"constant.cjs.cjs","sources":["../src/constant.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAa,MAAA,0BAA0B,GAAG,CAAC,QAAQ;;;;"}
@@ -1,6 +1,4 @@
1
- const FEDERATION_SUPPORTED_TYPES = [
2
- 'script'
3
- ];
1
+ const FEDERATION_SUPPORTED_TYPES = ['script'];
4
2
 
5
3
  export { FEDERATION_SUPPORTED_TYPES };
6
4
  //# sourceMappingURL=constant.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constant.esm.js","sources":["../../src/constant.ts"],"sourcesContent":[null],"names":["FEDERATION_SUPPORTED_TYPES"],"mappings":"MAAaA,0BAA6B,GAAA;AAAC,IAAA;AAAS;;;;"}
1
+ {"version":3,"file":"constant.esm.js","sources":["../src/constant.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAa,MAAA,0BAA0B,GAAG,CAAC,QAAQ;;;;"}
@@ -18,24 +18,168 @@ function _interopNamespaceDefault(e) {
18
18
  var runtime__namespace = /*#__PURE__*/_interopNamespaceDefault(runtime);
19
19
 
20
20
  function attachShareScopeMap(webpackRequire) {
21
- if (!webpackRequire.S || webpackRequire.federation.hasAttachShareScopeMap || !webpackRequire.federation.instance || !webpackRequire.federation.instance.shareScopeMap) {
21
+ if (!webpackRequire.S ||
22
+ webpackRequire.federation.hasAttachShareScopeMap ||
23
+ !webpackRequire.federation.instance ||
24
+ !webpackRequire.federation.instance.shareScopeMap) {
22
25
  return;
23
26
  }
24
27
  webpackRequire.S = webpackRequire.federation.instance.shareScopeMap;
25
28
  webpackRequire.federation.hasAttachShareScopeMap = true;
26
29
  }
27
30
 
31
+ function updateConsumeOptions(options) {
32
+ const { webpackRequire, moduleToHandlerMapping } = options;
33
+ const { consumesLoadingData, initializeSharingData } = webpackRequire;
34
+ if (consumesLoadingData && !consumesLoadingData._updated) {
35
+ const { moduleIdToConsumeDataMapping: updatedModuleIdToConsumeDataMapping = {}, initialConsumes: updatedInitialConsumes = [], chunkMapping: updatedChunkMapping = {}, } = consumesLoadingData;
36
+ Object.entries(updatedModuleIdToConsumeDataMapping).forEach(([id, data]) => {
37
+ if (!moduleToHandlerMapping[id]) {
38
+ moduleToHandlerMapping[id] = {
39
+ getter: data.fallback,
40
+ shareInfo: {
41
+ shareConfig: {
42
+ requiredVersion: data.requiredVersion,
43
+ strictVersion: data.strictVersion,
44
+ singleton: data.singleton,
45
+ eager: data.eager,
46
+ layer: data.layer,
47
+ },
48
+ scope: Array.isArray(data.shareScope)
49
+ ? data.shareScope
50
+ : [data.shareScope || 'default'],
51
+ },
52
+ shareKey: data.shareKey,
53
+ };
54
+ }
55
+ });
56
+ if ('initialConsumes' in options) {
57
+ const { initialConsumes = [] } = options;
58
+ updatedInitialConsumes.forEach((id) => {
59
+ if (!initialConsumes.includes(id)) {
60
+ initialConsumes.push(id);
61
+ }
62
+ });
63
+ }
64
+ if ('chunkMapping' in options) {
65
+ const { chunkMapping = {} } = options;
66
+ Object.entries(updatedChunkMapping).forEach(([id, chunkModules]) => {
67
+ if (!chunkMapping[id]) {
68
+ chunkMapping[id] = [];
69
+ }
70
+ chunkModules.forEach((moduleId) => {
71
+ if (!chunkMapping[id].includes(moduleId)) {
72
+ chunkMapping[id].push(moduleId);
73
+ }
74
+ });
75
+ });
76
+ }
77
+ consumesLoadingData._updated = 1;
78
+ }
79
+ if (initializeSharingData && !initializeSharingData._updated) {
80
+ const { federation } = webpackRequire;
81
+ if (!federation.instance ||
82
+ !initializeSharingData.scopeToSharingDataMapping) {
83
+ return;
84
+ }
85
+ const shared = {};
86
+ for (let [scope, stages] of Object.entries(initializeSharingData.scopeToSharingDataMapping)) {
87
+ for (let stage of stages) {
88
+ if (typeof stage === 'object' && stage !== null) {
89
+ const { name, version, factory, eager, singleton, requiredVersion, strictVersion, } = stage;
90
+ const shareConfig = {
91
+ requiredVersion: `^${version}`,
92
+ };
93
+ const isValidValue = function (val) {
94
+ return typeof val !== 'undefined';
95
+ };
96
+ if (isValidValue(singleton)) {
97
+ shareConfig.singleton = singleton;
98
+ }
99
+ if (isValidValue(requiredVersion)) {
100
+ shareConfig.requiredVersion = requiredVersion;
101
+ }
102
+ if (isValidValue(eager)) {
103
+ shareConfig.eager = eager;
104
+ }
105
+ if (isValidValue(strictVersion)) {
106
+ shareConfig.strictVersion = strictVersion;
107
+ }
108
+ const options = {
109
+ version,
110
+ scope: [scope],
111
+ shareConfig,
112
+ get: factory,
113
+ };
114
+ if (shared[name]) {
115
+ shared[name].push(options);
116
+ }
117
+ else {
118
+ shared[name] = [options];
119
+ }
120
+ }
121
+ }
122
+ }
123
+ federation.instance.registerShared(shared);
124
+ initializeSharingData._updated = 1;
125
+ }
126
+ }
127
+ function updateRemoteOptions(options) {
128
+ const { webpackRequire, idToExternalAndNameMapping = {}, idToRemoteMap = {}, chunkMapping = {}, } = options;
129
+ const { remotesLoadingData } = webpackRequire;
130
+ const remoteInfos = webpackRequire.federation?.bundlerRuntimeOptions?.remotes?.remoteInfos;
131
+ if (!remotesLoadingData || remotesLoadingData._updated || !remoteInfos) {
132
+ return;
133
+ }
134
+ const { chunkMapping: updatedChunkMapping, moduleIdToRemoteDataMapping } = remotesLoadingData;
135
+ if (!updatedChunkMapping || !moduleIdToRemoteDataMapping) {
136
+ return;
137
+ }
138
+ for (let [moduleId, data] of Object.entries(moduleIdToRemoteDataMapping)) {
139
+ if (!idToExternalAndNameMapping[moduleId]) {
140
+ idToExternalAndNameMapping[moduleId] = [
141
+ data.shareScope,
142
+ data.name,
143
+ data.externalModuleId,
144
+ ];
145
+ }
146
+ if (!idToRemoteMap[moduleId] && remoteInfos[data.remoteName]) {
147
+ const items = remoteInfos[data.remoteName];
148
+ idToRemoteMap[moduleId] ||= [];
149
+ items.forEach((item) => {
150
+ if (!idToRemoteMap[moduleId].includes(item)) {
151
+ idToRemoteMap[moduleId].push(item);
152
+ }
153
+ });
154
+ }
155
+ }
156
+ if (chunkMapping) {
157
+ Object.entries(updatedChunkMapping).forEach(([id, chunkModules]) => {
158
+ if (!chunkMapping[id]) {
159
+ chunkMapping[id] = [];
160
+ }
161
+ chunkModules.forEach((moduleId) => {
162
+ if (!chunkMapping[id].includes(moduleId)) {
163
+ chunkMapping[id].push(moduleId);
164
+ }
165
+ });
166
+ });
167
+ }
168
+ remotesLoadingData._updated = 1;
169
+ }
170
+
28
171
  function remotes(options) {
29
- const { chunkId, promises, chunkMapping, idToExternalAndNameMapping, webpackRequire, idToRemoteMap } = options;
172
+ updateRemoteOptions(options);
173
+ const { chunkId, promises, webpackRequire, chunkMapping, idToExternalAndNameMapping, idToRemoteMap, } = options;
30
174
  attachShareScopeMap(webpackRequire);
31
175
  if (webpackRequire.o(chunkMapping, chunkId)) {
32
- chunkMapping[chunkId].forEach((id)=>{
176
+ chunkMapping[chunkId].forEach((id) => {
33
177
  let getScope = webpackRequire.R;
34
178
  if (!getScope) {
35
179
  getScope = [];
36
180
  }
37
181
  const data = idToExternalAndNameMapping[id];
38
- const remoteInfos = idToRemoteMap[id];
182
+ const remoteInfos = idToRemoteMap[id] || [];
39
183
  // @ts-ignore seems not work
40
184
  if (getScope.indexOf(data) >= 0) {
41
185
  return;
@@ -45,68 +189,77 @@ function remotes(options) {
45
189
  if (data.p) {
46
190
  return promises.push(data.p);
47
191
  }
48
- const onError = (error)=>{
192
+ const onError = (error) => {
49
193
  if (!error) {
50
194
  error = new Error('Container missing');
51
195
  }
52
196
  if (typeof error.message === 'string') {
53
197
  error.message += `\nwhile loading "${data[1]}" from ${data[2]}`;
54
198
  }
55
- webpackRequire.m[id] = ()=>{
199
+ webpackRequire.m[id] = () => {
56
200
  throw error;
57
201
  };
58
202
  data.p = 0;
59
203
  };
60
- const handleFunction = (fn, arg1, arg2, d, next, first)=>{
204
+ const handleFunction = (fn, arg1, arg2, d, next, first) => {
61
205
  try {
62
206
  const promise = fn(arg1, arg2);
63
207
  if (promise && promise.then) {
64
- const p = promise.then((result)=>next(result, d), onError);
208
+ const p = promise.then((result) => next(result, d), onError);
65
209
  if (first) {
66
- promises.push(data.p = p);
67
- } else {
210
+ promises.push((data.p = p));
211
+ }
212
+ else {
68
213
  return p;
69
214
  }
70
- } else {
215
+ }
216
+ else {
71
217
  return next(promise, d, first);
72
218
  }
73
- } catch (error) {
219
+ }
220
+ catch (error) {
74
221
  onError(error);
75
222
  }
76
223
  };
77
- const onExternal = (external, _, first)=>external ? handleFunction(webpackRequire.I, data[0], 0, external, onInitialized, first) : onError();
224
+ const onExternal = (external, _, first) => external
225
+ ? handleFunction(webpackRequire.I, data[0], 0, external, onInitialized, first)
226
+ : onError();
78
227
  // eslint-disable-next-line no-var
79
- var onInitialized = (_, external, first)=>handleFunction(external.get, data[1], getScope, 0, onFactory, first);
228
+ var onInitialized = (_, external, first) => handleFunction(external.get, data[1], getScope, 0, onFactory, first);
80
229
  // eslint-disable-next-line no-var
81
- var onFactory = (factory)=>{
230
+ var onFactory = (factory) => {
82
231
  data.p = 1;
83
- webpackRequire.m[id] = (module)=>{
232
+ webpackRequire.m[id] = (module) => {
84
233
  module.exports = factory();
85
234
  };
86
235
  };
87
- const onRemoteLoaded = ()=>{
236
+ const onRemoteLoaded = () => {
88
237
  try {
89
238
  const remoteName = sdk.decodeName(remoteInfos[0].name, sdk.ENCODE_NAME_PREFIX);
90
239
  const remoteModuleName = remoteName + data[1].slice(1);
91
240
  const instance = webpackRequire.federation.instance;
92
- const loadRemote = ()=>webpackRequire.federation.instance.loadRemote(remoteModuleName, {
93
- loadFactory: false,
94
- from: 'build'
95
- });
241
+ const loadRemote = () => webpackRequire.federation.instance.loadRemote(remoteModuleName, {
242
+ loadFactory: false,
243
+ from: 'build',
244
+ });
96
245
  if (instance.options.shareStrategy === 'version-first') {
97
- return Promise.all(instance.sharedHandler.initializeSharing(data[0])).then(()=>{
246
+ return Promise.all(instance.sharedHandler.initializeSharing(data[0])).then(() => {
98
247
  return loadRemote();
99
248
  });
100
249
  }
101
250
  return loadRemote();
102
- } catch (error) {
251
+ }
252
+ catch (error) {
103
253
  onError(error);
104
254
  }
105
255
  };
106
- const useRuntimeLoad = remoteInfos.length === 1 && constant.FEDERATION_SUPPORTED_TYPES.includes(remoteInfos[0].externalType) && remoteInfos[0].name;
256
+ const useRuntimeLoad = remoteInfos.length === 1 &&
257
+ constant.FEDERATION_SUPPORTED_TYPES.includes(remoteInfos[0].externalType) &&
258
+ remoteInfos[0].name;
107
259
  if (useRuntimeLoad) {
108
260
  handleFunction(onRemoteLoaded, data[2], 0, 0, onFactory, 1);
109
- } else {
261
+ }
262
+ else {
110
263
  handleFunction(webpackRequire, data[2], 0, 0, onExternal, 1);
111
264
  }
112
265
  });
@@ -114,37 +267,41 @@ function remotes(options) {
114
267
  }
115
268
 
116
269
  function consumes(options) {
117
- const { chunkId, promises, chunkMapping, installedModules, moduleToHandlerMapping, webpackRequire } = options;
270
+ updateConsumeOptions(options);
271
+ const { chunkId, promises, installedModules, webpackRequire, chunkMapping, moduleToHandlerMapping, } = options;
118
272
  attachShareScopeMap(webpackRequire);
119
273
  if (webpackRequire.o(chunkMapping, chunkId)) {
120
- chunkMapping[chunkId].forEach((id)=>{
274
+ chunkMapping[chunkId].forEach((id) => {
121
275
  if (webpackRequire.o(installedModules, id)) {
122
276
  return promises.push(installedModules[id]);
123
277
  }
124
- const onFactory = (factory)=>{
278
+ const onFactory = (factory) => {
125
279
  installedModules[id] = 0;
126
- webpackRequire.m[id] = (module)=>{
127
- var _shareInfo_shareConfig;
280
+ webpackRequire.m[id] = (module) => {
128
281
  delete webpackRequire.c[id];
129
282
  const result = factory();
130
283
  // Add layer property from shareConfig if available
131
284
  const { shareInfo } = moduleToHandlerMapping[id];
132
- if ((shareInfo == null ? void 0 : (_shareInfo_shareConfig = shareInfo.shareConfig) == null ? void 0 : _shareInfo_shareConfig.layer) && result && typeof result === 'object') {
285
+ if (shareInfo?.shareConfig?.layer &&
286
+ result &&
287
+ typeof result === 'object') {
133
288
  try {
134
289
  // Only set layer if it's not already defined or if it's undefined
135
- if (!result.hasOwnProperty('layer') || result.layer === undefined) {
290
+ if (!result.hasOwnProperty('layer') ||
291
+ result.layer === undefined) {
136
292
  result.layer = shareInfo.shareConfig.layer;
137
293
  }
138
- } catch (e) {
139
- // Ignore if layer property is read-only
294
+ }
295
+ catch (e) {
296
+ // Ignore if layer property is read-only
140
297
  }
141
298
  }
142
299
  module.exports = result;
143
300
  };
144
301
  };
145
- const onError = (error)=>{
302
+ const onError = (error) => {
146
303
  delete installedModules[id];
147
- webpackRequire.m[id] = (module)=>{
304
+ webpackRequire.m[id] = (module) => {
148
305
  delete webpackRequire.c[id];
149
306
  throw error;
150
307
  };
@@ -155,78 +312,89 @@ function consumes(options) {
155
312
  throw new Error('Federation instance not found!');
156
313
  }
157
314
  const { shareKey, getter, shareInfo } = moduleToHandlerMapping[id];
158
- const promise = federationInstance.loadShare(shareKey, {
159
- customShareInfo: shareInfo
160
- }).then((factory)=>{
315
+ const promise = federationInstance
316
+ .loadShare(shareKey, { customShareInfo: shareInfo })
317
+ .then((factory) => {
161
318
  if (factory === false) {
162
319
  return getter();
163
320
  }
164
321
  return factory;
165
322
  });
166
323
  if (promise.then) {
167
- promises.push(installedModules[id] = promise.then(onFactory).catch(onError));
168
- } else {
324
+ promises.push((installedModules[id] = promise.then(onFactory).catch(onError)));
325
+ }
326
+ else {
169
327
  // @ts-ignore maintain previous logic
170
328
  onFactory(promise);
171
329
  }
172
- } catch (e) {
330
+ }
331
+ catch (e) {
173
332
  onError(e);
174
333
  }
175
334
  });
176
335
  }
177
336
  }
178
337
 
179
- function initializeSharing({ shareScopeName, webpackRequire, initPromises, initTokens, initScope }) {
180
- const shareScopeKeys = Array.isArray(shareScopeName) ? shareScopeName : [
181
- shareScopeName
182
- ];
338
+ function initializeSharing({ shareScopeName, webpackRequire, initPromises, initTokens, initScope, }) {
339
+ const shareScopeKeys = Array.isArray(shareScopeName)
340
+ ? shareScopeName
341
+ : [shareScopeName];
183
342
  var initializeSharingPromises = [];
184
- var _initializeSharing = function(shareScopeKey) {
185
- if (!initScope) initScope = [];
343
+ var _initializeSharing = function (shareScopeKey) {
344
+ if (!initScope)
345
+ initScope = [];
186
346
  const mfInstance = webpackRequire.federation.instance;
187
347
  // handling circular init calls
188
348
  var initToken = initTokens[shareScopeKey];
189
- if (!initToken) initToken = initTokens[shareScopeKey] = {
190
- from: mfInstance.name
191
- };
192
- if (initScope.indexOf(initToken) >= 0) return;
349
+ if (!initToken)
350
+ initToken = initTokens[shareScopeKey] = { from: mfInstance.name };
351
+ if (initScope.indexOf(initToken) >= 0)
352
+ return;
193
353
  initScope.push(initToken);
194
354
  const promise = initPromises[shareScopeKey];
195
- if (promise) return promise;
196
- var warn = (msg)=>typeof console !== 'undefined' && console.warn && console.warn(msg);
197
- var initExternal = (id)=>{
198
- var handleError = (err)=>warn('Initialization of sharing external failed: ' + err);
355
+ if (promise)
356
+ return promise;
357
+ var warn = (msg) => typeof console !== 'undefined' && console.warn && console.warn(msg);
358
+ var initExternal = (id) => {
359
+ var handleError = (err) => warn('Initialization of sharing external failed: ' + err);
199
360
  try {
200
361
  var module = webpackRequire(id);
201
- if (!module) return;
202
- var initFn = (module)=>module && module.init && // @ts-ignore compat legacy mf shared behavior
362
+ if (!module)
363
+ return;
364
+ var initFn = (module) => module &&
365
+ module.init &&
366
+ // @ts-ignore compat legacy mf shared behavior
203
367
  module.init(webpackRequire.S[shareScopeKey], initScope, {
204
368
  shareScopeMap: webpackRequire.S || {},
205
- shareScopeKeys: shareScopeName
369
+ shareScopeKeys: shareScopeName,
206
370
  });
207
- if (module.then) return promises.push(module.then(initFn, handleError));
371
+ if (module.then)
372
+ return promises.push(module.then(initFn, handleError));
208
373
  var initResult = initFn(module);
209
374
  // @ts-ignore
210
- if (initResult && typeof initResult !== 'boolean' && initResult.then) // @ts-ignore
211
- return promises.push(initResult['catch'](handleError));
212
- } catch (err) {
375
+ if (initResult && typeof initResult !== 'boolean' && initResult.then)
376
+ // @ts-ignore
377
+ return promises.push(initResult['catch'](handleError));
378
+ }
379
+ catch (err) {
213
380
  handleError(err);
214
381
  }
215
382
  };
216
383
  const promises = mfInstance.initializeSharing(shareScopeKey, {
217
384
  strategy: mfInstance.options.shareStrategy,
218
385
  initScope,
219
- from: 'build'
386
+ from: 'build',
220
387
  });
221
388
  attachShareScopeMap(webpackRequire);
222
389
  const bundlerRuntimeRemotesOptions = webpackRequire.federation.bundlerRuntimeOptions.remotes;
223
390
  if (bundlerRuntimeRemotesOptions) {
224
- Object.keys(bundlerRuntimeRemotesOptions.idToRemoteMap).forEach((moduleId)=>{
391
+ Object.keys(bundlerRuntimeRemotesOptions.idToRemoteMap).forEach((moduleId) => {
225
392
  const info = bundlerRuntimeRemotesOptions.idToRemoteMap[moduleId];
226
393
  const externalModuleId = bundlerRuntimeRemotesOptions.idToExternalAndNameMapping[moduleId][2];
227
394
  if (info.length > 1) {
228
395
  initExternal(externalModuleId);
229
- } else if (info.length === 1) {
396
+ }
397
+ else if (info.length === 1) {
230
398
  const remoteInfo = info[0];
231
399
  if (!constant.FEDERATION_SUPPORTED_TYPES.includes(remoteInfo.externalType)) {
232
400
  initExternal(externalModuleId);
@@ -235,14 +403,14 @@ function initializeSharing({ shareScopeName, webpackRequire, initPromises, initT
235
403
  });
236
404
  }
237
405
  if (!promises.length) {
238
- return initPromises[shareScopeKey] = true;
406
+ return (initPromises[shareScopeKey] = true);
239
407
  }
240
- return initPromises[shareScopeKey] = Promise.all(promises).then(()=>initPromises[shareScopeKey] = true);
408
+ return (initPromises[shareScopeKey] = Promise.all(promises).then(() => (initPromises[shareScopeKey] = true)));
241
409
  };
242
- shareScopeKeys.forEach((key)=>{
410
+ shareScopeKeys.forEach((key) => {
243
411
  initializeSharingPromises.push(_initializeSharing(key));
244
412
  });
245
- return Promise.all(initializeSharingPromises).then(()=>true);
413
+ return Promise.all(initializeSharingPromises).then(() => true);
246
414
  }
247
415
 
248
416
  function handleInitialConsumes(options) {
@@ -254,26 +422,28 @@ function handleInitialConsumes(options) {
254
422
  const { shareKey, shareInfo } = moduleToHandlerMapping[moduleId];
255
423
  try {
256
424
  return federationInstance.loadShareSync(shareKey, {
257
- customShareInfo: shareInfo
425
+ customShareInfo: shareInfo,
258
426
  });
259
- } catch (err) {
427
+ }
428
+ catch (err) {
260
429
  console.error('loadShareSync failed! The function should not be called unless you set "eager:true". If you do not set it, and encounter this issue, you can check whether an async boundary is implemented.');
261
430
  console.error('The original error message is as follows: ');
262
431
  throw err;
263
432
  }
264
433
  }
265
434
  function installInitialConsumes(options) {
266
- const { moduleToHandlerMapping, webpackRequire, installedModules, initialConsumes } = options;
267
- initialConsumes.forEach((id)=>{
268
- webpackRequire.m[id] = (module)=>{
269
- var _shareInfo_shareConfig;
435
+ const { webpackRequire } = options;
436
+ updateConsumeOptions(options);
437
+ const { initialConsumes, moduleToHandlerMapping, installedModules } = options;
438
+ initialConsumes.forEach((id) => {
439
+ webpackRequire.m[id] = (module) => {
270
440
  // Handle scenario when module is used synchronously
271
441
  installedModules[id] = 0;
272
442
  delete webpackRequire.c[id];
273
443
  const factory = handleInitialConsumes({
274
444
  moduleId: id,
275
445
  moduleToHandlerMapping,
276
- webpackRequire
446
+ webpackRequire,
277
447
  });
278
448
  if (typeof factory !== 'function') {
279
449
  throw new Error(`Shared module is not available for eager consumption: ${id}`);
@@ -281,14 +451,18 @@ function installInitialConsumes(options) {
281
451
  const result = factory();
282
452
  // Add layer property from shareConfig if available
283
453
  const { shareInfo } = moduleToHandlerMapping[id];
284
- if ((shareInfo == null ? void 0 : (_shareInfo_shareConfig = shareInfo.shareConfig) == null ? void 0 : _shareInfo_shareConfig.layer) && result && typeof result === 'object') {
454
+ if (shareInfo?.shareConfig?.layer &&
455
+ result &&
456
+ typeof result === 'object') {
285
457
  try {
286
458
  // Only set layer if it's not already defined or if it's undefined
287
- if (!result.hasOwnProperty('layer') || result.layer === undefined) {
459
+ if (!result.hasOwnProperty('layer') ||
460
+ result.layer === undefined) {
288
461
  result.layer = shareInfo.shareConfig.layer;
289
462
  }
290
- } catch (e) {
291
- // Ignore if layer property is read-only
463
+ }
464
+ catch (e) {
465
+ // Ignore if layer property is read-only
292
466
  }
293
467
  }
294
468
  module.exports = result;
@@ -296,28 +470,22 @@ function installInitialConsumes(options) {
296
470
  });
297
471
  }
298
472
 
299
- function _extends() {
300
- _extends = Object.assign || function assign(target) {
301
- for(var i = 1; i < arguments.length; i++){
302
- var source = arguments[i];
303
- for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
304
- }
305
- return target;
306
- };
307
- return _extends.apply(this, arguments);
308
- }
309
-
310
473
  function initContainerEntry(options) {
311
- const { webpackRequire, shareScope, initScope, shareScopeKey, remoteEntryInitOptions } = options;
312
- if (!webpackRequire.S) return;
313
- if (!webpackRequire.federation || !webpackRequire.federation.instance || !webpackRequire.federation.initOptions) return;
474
+ const { webpackRequire, shareScope, initScope, shareScopeKey, remoteEntryInitOptions, } = options;
475
+ if (!webpackRequire.S)
476
+ return;
477
+ if (!webpackRequire.federation ||
478
+ !webpackRequire.federation.instance ||
479
+ !webpackRequire.federation.initOptions)
480
+ return;
314
481
  const federationInstance = webpackRequire.federation.instance;
315
- federationInstance.initOptions(_extends({
482
+ federationInstance.initOptions({
316
483
  name: webpackRequire.federation.initOptions.name,
317
- remotes: []
318
- }, remoteEntryInitOptions));
319
- const hostShareScopeKeys = remoteEntryInitOptions == null ? void 0 : remoteEntryInitOptions.shareScopeKeys;
320
- const hostShareScopeMap = remoteEntryInitOptions == null ? void 0 : remoteEntryInitOptions.shareScopeMap;
484
+ remotes: [],
485
+ ...remoteEntryInitOptions,
486
+ });
487
+ const hostShareScopeKeys = remoteEntryInitOptions?.shareScopeKeys;
488
+ const hostShareScopeMap = remoteEntryInitOptions?.shareScopeMap;
321
489
  // host: 'default' remote: 'default' remote['default'] = hostShareScopeMap['default']
322
490
  // host: ['default', 'scope1'] remote: 'default' remote['default'] = hostShareScopeMap['default']; remote['scope1'] = hostShareScopeMap['scop1']
323
491
  // host: 'default' remote: ['default','scope1'] remote['default'] = hostShareScopeMap['default']; remote['scope1'] = hostShareScopeMap['scope1'] = {}
@@ -332,25 +500,27 @@ function initContainerEntry(options) {
332
500
  // federationInstance.initShareScopeMap(key, sc, {
333
501
  // hostShareScopeMap: remoteEntryInitOptions?.shareScopeMap || {},
334
502
  // });
335
- hostShareScopeKeys.forEach((hostKey)=>{
503
+ hostShareScopeKeys.forEach((hostKey) => {
336
504
  if (!hostShareScopeMap[hostKey]) {
337
505
  hostShareScopeMap[hostKey] = {};
338
506
  }
339
507
  const sc = hostShareScopeMap[hostKey];
340
508
  federationInstance.initShareScopeMap(hostKey, sc, {
341
- hostShareScopeMap: (remoteEntryInitOptions == null ? void 0 : remoteEntryInitOptions.shareScopeMap) || {}
509
+ hostShareScopeMap: remoteEntryInitOptions?.shareScopeMap || {},
342
510
  });
343
511
  });
344
- } else {
512
+ }
513
+ else {
345
514
  federationInstance.initShareScopeMap(key, shareScope, {
346
- hostShareScopeMap: (remoteEntryInitOptions == null ? void 0 : remoteEntryInitOptions.shareScopeMap) || {}
515
+ hostShareScopeMap: remoteEntryInitOptions?.shareScopeMap || {},
347
516
  });
348
517
  }
349
- } else {
350
- shareScopeKey.forEach((key)=>{
518
+ }
519
+ else {
520
+ shareScopeKey.forEach((key) => {
351
521
  if (!hostShareScopeKeys || !hostShareScopeMap) {
352
522
  federationInstance.initShareScopeMap(key, shareScope, {
353
- hostShareScopeMap: (remoteEntryInitOptions == null ? void 0 : remoteEntryInitOptions.shareScopeMap) || {}
523
+ hostShareScopeMap: remoteEntryInitOptions?.shareScopeMap || {},
354
524
  });
355
525
  return;
356
526
  }
@@ -359,7 +529,7 @@ function initContainerEntry(options) {
359
529
  }
360
530
  const sc = hostShareScopeMap[key];
361
531
  federationInstance.initShareScopeMap(key, sc, {
362
- hostShareScopeMap: (remoteEntryInitOptions == null ? void 0 : remoteEntryInitOptions.shareScopeMap) || {}
532
+ hostShareScopeMap: remoteEntryInitOptions?.shareScopeMap || {},
363
533
  });
364
534
  });
365
535
  }
@@ -379,10 +549,10 @@ function initContainerEntry(options) {
379
549
  return webpackRequire.I(shareScopeKey, initScope);
380
550
  }
381
551
  // @ts-ignore
382
- return Promise.all(shareScopeKey.map((key)=>{
552
+ return Promise.all(shareScopeKey.map((key) => {
383
553
  // @ts-ignore
384
554
  return webpackRequire.I(key, initScope);
385
- })).then(()=>true);
555
+ })).then(() => true);
386
556
  }
387
557
 
388
558
  const federation = {
@@ -395,10 +565,10 @@ const federation = {
395
565
  I: initializeSharing,
396
566
  S: {},
397
567
  installInitialConsumes,
398
- initContainerEntry
568
+ initContainerEntry,
399
569
  },
400
570
  attachShareScopeMap,
401
- bundlerRuntimeOptions: {}
571
+ bundlerRuntimeOptions: {},
402
572
  };
403
573
 
404
574
  module.exports = federation;