@module-federation/webpack-bundler-runtime 0.0.0-next-20250925034616 → 0.0.0-refactor-manifest-20251013103938

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