@module-federation/runtime-core 0.18.0 → 0.18.2

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.
@@ -202,7 +202,7 @@ function getGlobalFederationConstructor() {
202
202
  function setGlobalFederationConstructor(FederationConstructor, isDebug = sdk.isDebugMode()) {
203
203
  if (isDebug) {
204
204
  CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
205
- CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.18.0";
205
+ CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.18.2";
206
206
  }
207
207
  }
208
208
  // eslint-disable-next-line @typescript-eslint/ban-types
@@ -2247,30 +2247,30 @@ class SharedHandler {
2247
2247
  // 1. Checks if the currently loaded share already exists, if not, it throws an error
2248
2248
  // 2. Searches globally for a matching share, if found, it uses it directly
2249
2249
  // 3. If not found, it retrieves it from the current share and stores the obtained share globally.
2250
- const shareInfo = getTargetSharedOptions({
2250
+ const shareOptions = getTargetSharedOptions({
2251
2251
  pkgName,
2252
2252
  extraOptions,
2253
2253
  shareInfos: host.options.shared
2254
2254
  });
2255
- if (shareInfo == null ? void 0 : shareInfo.scope) {
2256
- await Promise.all(shareInfo.scope.map(async (shareScope)=>{
2255
+ if (shareOptions == null ? void 0 : shareOptions.scope) {
2256
+ await Promise.all(shareOptions.scope.map(async (shareScope)=>{
2257
2257
  await Promise.all(this.initializeSharing(shareScope, {
2258
- strategy: shareInfo.strategy
2258
+ strategy: shareOptions.strategy
2259
2259
  }));
2260
2260
  return;
2261
2261
  }));
2262
2262
  }
2263
2263
  const loadShareRes = await this.hooks.lifecycle.beforeLoadShare.emit({
2264
2264
  pkgName,
2265
- shareInfo,
2265
+ shareInfo: shareOptions,
2266
2266
  shared: host.options.shared,
2267
2267
  origin: host
2268
2268
  });
2269
- const { shareInfo: shareInfoRes } = loadShareRes;
2269
+ const { shareInfo: shareOptionsRes } = loadShareRes;
2270
2270
  // Assert that shareInfoRes exists, if not, throw an error
2271
- assert(shareInfoRes, `Cannot find ${pkgName} Share in the ${host.options.name}. Please ensure that the ${pkgName} Share parameters have been injected`);
2271
+ assert(shareOptionsRes, `Cannot find ${pkgName} Share in the ${host.options.name}. Please ensure that the ${pkgName} Share parameters have been injected`);
2272
2272
  // Retrieve from cache
2273
- const registeredShared = getRegisteredShare(this.shareScopeMap, pkgName, shareInfoRes, this.hooks.lifecycle.resolveShare);
2273
+ const registeredShared = getRegisteredShare(this.shareScopeMap, pkgName, shareOptionsRes, this.hooks.lifecycle.resolveShare);
2274
2274
  const addUseIn = (shared)=>{
2275
2275
  if (!shared.useIn) {
2276
2276
  shared.useIn = [];
@@ -2291,15 +2291,9 @@ class SharedHandler {
2291
2291
  } else if (registeredShared) {
2292
2292
  const asyncLoadProcess = async ()=>{
2293
2293
  const factory = await registeredShared.get();
2294
- shareInfoRes.lib = factory;
2295
- shareInfoRes.loaded = true;
2296
- addUseIn(shareInfoRes);
2297
- const gShared = getRegisteredShare(this.shareScopeMap, pkgName, shareInfoRes, this.hooks.lifecycle.resolveShare);
2298
- if (gShared) {
2299
- gShared.lib = factory;
2300
- gShared.loaded = true;
2301
- addUseIn(gShared);
2302
- }
2294
+ addUseIn(registeredShared);
2295
+ registeredShared.loaded = true;
2296
+ registeredShared.lib = factory;
2303
2297
  return factory;
2304
2298
  };
2305
2299
  const loading = asyncLoadProcess();
@@ -2317,14 +2311,15 @@ class SharedHandler {
2317
2311
  return false;
2318
2312
  }
2319
2313
  const asyncLoadProcess = async ()=>{
2320
- const factory = await shareInfoRes.get();
2321
- shareInfoRes.lib = factory;
2322
- shareInfoRes.loaded = true;
2323
- addUseIn(shareInfoRes);
2324
- const gShared = getRegisteredShare(this.shareScopeMap, pkgName, shareInfoRes, this.hooks.lifecycle.resolveShare);
2314
+ const factory = await shareOptionsRes.get();
2315
+ shareOptionsRes.lib = factory;
2316
+ shareOptionsRes.loaded = true;
2317
+ addUseIn(shareOptionsRes);
2318
+ const gShared = getRegisteredShare(this.shareScopeMap, pkgName, shareOptionsRes, this.hooks.lifecycle.resolveShare);
2325
2319
  if (gShared) {
2326
2320
  gShared.lib = factory;
2327
2321
  gShared.loaded = true;
2322
+ gShared.from = shareOptionsRes.from;
2328
2323
  }
2329
2324
  return factory;
2330
2325
  };
@@ -2332,7 +2327,7 @@ class SharedHandler {
2332
2327
  this.setShared({
2333
2328
  pkgName,
2334
2329
  loaded: false,
2335
- shared: shareInfoRes,
2330
+ shared: shareOptionsRes,
2336
2331
  from: host.options.name,
2337
2332
  lib: null,
2338
2333
  loading
@@ -2428,19 +2423,19 @@ class SharedHandler {
2428
2423
  // 3. If the local get returns something other than Promise, then it will be used directly
2429
2424
  loadShareSync(pkgName, extraOptions) {
2430
2425
  const { host } = this;
2431
- const shareInfo = getTargetSharedOptions({
2426
+ const shareOptions = getTargetSharedOptions({
2432
2427
  pkgName,
2433
2428
  extraOptions,
2434
2429
  shareInfos: host.options.shared
2435
2430
  });
2436
- if (shareInfo == null ? void 0 : shareInfo.scope) {
2437
- shareInfo.scope.forEach((shareScope)=>{
2431
+ if (shareOptions == null ? void 0 : shareOptions.scope) {
2432
+ shareOptions.scope.forEach((shareScope)=>{
2438
2433
  this.initializeSharing(shareScope, {
2439
- strategy: shareInfo.strategy
2434
+ strategy: shareOptions.strategy
2440
2435
  });
2441
2436
  });
2442
2437
  }
2443
- const registeredShared = getRegisteredShare(this.shareScopeMap, pkgName, shareInfo, this.hooks.lifecycle.resolveShare);
2438
+ const registeredShared = getRegisteredShare(this.shareScopeMap, pkgName, shareOptions, this.hooks.lifecycle.resolveShare);
2444
2439
  const addUseIn = (shared)=>{
2445
2440
  if (!shared.useIn) {
2446
2441
  shared.useIn = [];
@@ -2453,7 +2448,7 @@ class SharedHandler {
2453
2448
  if (!registeredShared.loaded) {
2454
2449
  registeredShared.loaded = true;
2455
2450
  if (registeredShared.from === host.options.name) {
2456
- shareInfo.loaded = true;
2451
+ shareOptions.loaded = true;
2457
2452
  }
2458
2453
  }
2459
2454
  return registeredShared.lib;
@@ -2473,14 +2468,14 @@ class SharedHandler {
2473
2468
  }
2474
2469
  }
2475
2470
  }
2476
- if (shareInfo.lib) {
2477
- if (!shareInfo.loaded) {
2478
- shareInfo.loaded = true;
2471
+ if (shareOptions.lib) {
2472
+ if (!shareOptions.loaded) {
2473
+ shareOptions.loaded = true;
2479
2474
  }
2480
- return shareInfo.lib;
2475
+ return shareOptions.lib;
2481
2476
  }
2482
- if (shareInfo.get) {
2483
- const module = shareInfo.get();
2477
+ if (shareOptions.get) {
2478
+ const module = shareOptions.get();
2484
2479
  if (module instanceof Promise) {
2485
2480
  const errorCode = (extraOptions == null ? void 0 : extraOptions.from) === 'build' ? errorCodes.RUNTIME_005 : errorCodes.RUNTIME_006;
2486
2481
  throw new Error(errorCodes.getShortErrorMsg(errorCode, errorCodes.runtimeDescMap, {
@@ -2488,15 +2483,15 @@ class SharedHandler {
2488
2483
  sharedPkgName: pkgName
2489
2484
  }));
2490
2485
  }
2491
- shareInfo.lib = module;
2486
+ shareOptions.lib = module;
2492
2487
  this.setShared({
2493
2488
  pkgName,
2494
2489
  loaded: true,
2495
2490
  from: host.options.name,
2496
- lib: shareInfo.lib,
2497
- shared: shareInfo
2491
+ lib: shareOptions.lib,
2492
+ shared: shareOptions
2498
2493
  });
2499
- return shareInfo.lib;
2494
+ return shareOptions.lib;
2500
2495
  }
2501
2496
  throw new Error(errorCodes.getShortErrorMsg(errorCodes.RUNTIME_006, errorCodes.runtimeDescMap, {
2502
2497
  hostName: host.options.name,
@@ -2549,6 +2544,12 @@ class SharedHandler {
2549
2544
  if (loading && !registeredShared.loading) {
2550
2545
  registeredShared.loading = loading;
2551
2546
  }
2547
+ if (loaded && !registeredShared.loaded) {
2548
+ registeredShared.loaded = loaded;
2549
+ }
2550
+ if (from && registeredShared.from !== from) {
2551
+ registeredShared.from = from;
2552
+ }
2552
2553
  });
2553
2554
  }
2554
2555
  _setGlobalShareScopeMap(hostOptions) {
@@ -3034,7 +3035,7 @@ class ModuleFederation {
3034
3035
  // maybe will change, temporarily for internal use only
3035
3036
  initContainer: new AsyncWaterfallHook('initContainer')
3036
3037
  });
3037
- this.version = "0.18.0";
3038
+ this.version = "0.18.2";
3038
3039
  this.moduleCache = new Map();
3039
3040
  this.loaderHook = new PluginSystem({
3040
3041
  // FIXME: may not be suitable , not open to the public yet
package/dist/index.esm.js CHANGED
@@ -201,7 +201,7 @@ function getGlobalFederationConstructor() {
201
201
  function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
202
202
  if (isDebug) {
203
203
  CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
204
- CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.18.0";
204
+ CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.18.2";
205
205
  }
206
206
  }
207
207
  // eslint-disable-next-line @typescript-eslint/ban-types
@@ -2246,30 +2246,30 @@ class SharedHandler {
2246
2246
  // 1. Checks if the currently loaded share already exists, if not, it throws an error
2247
2247
  // 2. Searches globally for a matching share, if found, it uses it directly
2248
2248
  // 3. If not found, it retrieves it from the current share and stores the obtained share globally.
2249
- const shareInfo = getTargetSharedOptions({
2249
+ const shareOptions = getTargetSharedOptions({
2250
2250
  pkgName,
2251
2251
  extraOptions,
2252
2252
  shareInfos: host.options.shared
2253
2253
  });
2254
- if (shareInfo == null ? void 0 : shareInfo.scope) {
2255
- await Promise.all(shareInfo.scope.map(async (shareScope)=>{
2254
+ if (shareOptions == null ? void 0 : shareOptions.scope) {
2255
+ await Promise.all(shareOptions.scope.map(async (shareScope)=>{
2256
2256
  await Promise.all(this.initializeSharing(shareScope, {
2257
- strategy: shareInfo.strategy
2257
+ strategy: shareOptions.strategy
2258
2258
  }));
2259
2259
  return;
2260
2260
  }));
2261
2261
  }
2262
2262
  const loadShareRes = await this.hooks.lifecycle.beforeLoadShare.emit({
2263
2263
  pkgName,
2264
- shareInfo,
2264
+ shareInfo: shareOptions,
2265
2265
  shared: host.options.shared,
2266
2266
  origin: host
2267
2267
  });
2268
- const { shareInfo: shareInfoRes } = loadShareRes;
2268
+ const { shareInfo: shareOptionsRes } = loadShareRes;
2269
2269
  // Assert that shareInfoRes exists, if not, throw an error
2270
- assert(shareInfoRes, `Cannot find ${pkgName} Share in the ${host.options.name}. Please ensure that the ${pkgName} Share parameters have been injected`);
2270
+ assert(shareOptionsRes, `Cannot find ${pkgName} Share in the ${host.options.name}. Please ensure that the ${pkgName} Share parameters have been injected`);
2271
2271
  // Retrieve from cache
2272
- const registeredShared = getRegisteredShare(this.shareScopeMap, pkgName, shareInfoRes, this.hooks.lifecycle.resolveShare);
2272
+ const registeredShared = getRegisteredShare(this.shareScopeMap, pkgName, shareOptionsRes, this.hooks.lifecycle.resolveShare);
2273
2273
  const addUseIn = (shared)=>{
2274
2274
  if (!shared.useIn) {
2275
2275
  shared.useIn = [];
@@ -2290,15 +2290,9 @@ class SharedHandler {
2290
2290
  } else if (registeredShared) {
2291
2291
  const asyncLoadProcess = async ()=>{
2292
2292
  const factory = await registeredShared.get();
2293
- shareInfoRes.lib = factory;
2294
- shareInfoRes.loaded = true;
2295
- addUseIn(shareInfoRes);
2296
- const gShared = getRegisteredShare(this.shareScopeMap, pkgName, shareInfoRes, this.hooks.lifecycle.resolveShare);
2297
- if (gShared) {
2298
- gShared.lib = factory;
2299
- gShared.loaded = true;
2300
- addUseIn(gShared);
2301
- }
2293
+ addUseIn(registeredShared);
2294
+ registeredShared.loaded = true;
2295
+ registeredShared.lib = factory;
2302
2296
  return factory;
2303
2297
  };
2304
2298
  const loading = asyncLoadProcess();
@@ -2316,14 +2310,15 @@ class SharedHandler {
2316
2310
  return false;
2317
2311
  }
2318
2312
  const asyncLoadProcess = async ()=>{
2319
- const factory = await shareInfoRes.get();
2320
- shareInfoRes.lib = factory;
2321
- shareInfoRes.loaded = true;
2322
- addUseIn(shareInfoRes);
2323
- const gShared = getRegisteredShare(this.shareScopeMap, pkgName, shareInfoRes, this.hooks.lifecycle.resolveShare);
2313
+ const factory = await shareOptionsRes.get();
2314
+ shareOptionsRes.lib = factory;
2315
+ shareOptionsRes.loaded = true;
2316
+ addUseIn(shareOptionsRes);
2317
+ const gShared = getRegisteredShare(this.shareScopeMap, pkgName, shareOptionsRes, this.hooks.lifecycle.resolveShare);
2324
2318
  if (gShared) {
2325
2319
  gShared.lib = factory;
2326
2320
  gShared.loaded = true;
2321
+ gShared.from = shareOptionsRes.from;
2327
2322
  }
2328
2323
  return factory;
2329
2324
  };
@@ -2331,7 +2326,7 @@ class SharedHandler {
2331
2326
  this.setShared({
2332
2327
  pkgName,
2333
2328
  loaded: false,
2334
- shared: shareInfoRes,
2329
+ shared: shareOptionsRes,
2335
2330
  from: host.options.name,
2336
2331
  lib: null,
2337
2332
  loading
@@ -2427,19 +2422,19 @@ class SharedHandler {
2427
2422
  // 3. If the local get returns something other than Promise, then it will be used directly
2428
2423
  loadShareSync(pkgName, extraOptions) {
2429
2424
  const { host } = this;
2430
- const shareInfo = getTargetSharedOptions({
2425
+ const shareOptions = getTargetSharedOptions({
2431
2426
  pkgName,
2432
2427
  extraOptions,
2433
2428
  shareInfos: host.options.shared
2434
2429
  });
2435
- if (shareInfo == null ? void 0 : shareInfo.scope) {
2436
- shareInfo.scope.forEach((shareScope)=>{
2430
+ if (shareOptions == null ? void 0 : shareOptions.scope) {
2431
+ shareOptions.scope.forEach((shareScope)=>{
2437
2432
  this.initializeSharing(shareScope, {
2438
- strategy: shareInfo.strategy
2433
+ strategy: shareOptions.strategy
2439
2434
  });
2440
2435
  });
2441
2436
  }
2442
- const registeredShared = getRegisteredShare(this.shareScopeMap, pkgName, shareInfo, this.hooks.lifecycle.resolveShare);
2437
+ const registeredShared = getRegisteredShare(this.shareScopeMap, pkgName, shareOptions, this.hooks.lifecycle.resolveShare);
2443
2438
  const addUseIn = (shared)=>{
2444
2439
  if (!shared.useIn) {
2445
2440
  shared.useIn = [];
@@ -2452,7 +2447,7 @@ class SharedHandler {
2452
2447
  if (!registeredShared.loaded) {
2453
2448
  registeredShared.loaded = true;
2454
2449
  if (registeredShared.from === host.options.name) {
2455
- shareInfo.loaded = true;
2450
+ shareOptions.loaded = true;
2456
2451
  }
2457
2452
  }
2458
2453
  return registeredShared.lib;
@@ -2472,14 +2467,14 @@ class SharedHandler {
2472
2467
  }
2473
2468
  }
2474
2469
  }
2475
- if (shareInfo.lib) {
2476
- if (!shareInfo.loaded) {
2477
- shareInfo.loaded = true;
2470
+ if (shareOptions.lib) {
2471
+ if (!shareOptions.loaded) {
2472
+ shareOptions.loaded = true;
2478
2473
  }
2479
- return shareInfo.lib;
2474
+ return shareOptions.lib;
2480
2475
  }
2481
- if (shareInfo.get) {
2482
- const module = shareInfo.get();
2476
+ if (shareOptions.get) {
2477
+ const module = shareOptions.get();
2483
2478
  if (module instanceof Promise) {
2484
2479
  const errorCode = (extraOptions == null ? void 0 : extraOptions.from) === 'build' ? RUNTIME_005 : RUNTIME_006;
2485
2480
  throw new Error(getShortErrorMsg(errorCode, runtimeDescMap, {
@@ -2487,15 +2482,15 @@ class SharedHandler {
2487
2482
  sharedPkgName: pkgName
2488
2483
  }));
2489
2484
  }
2490
- shareInfo.lib = module;
2485
+ shareOptions.lib = module;
2491
2486
  this.setShared({
2492
2487
  pkgName,
2493
2488
  loaded: true,
2494
2489
  from: host.options.name,
2495
- lib: shareInfo.lib,
2496
- shared: shareInfo
2490
+ lib: shareOptions.lib,
2491
+ shared: shareOptions
2497
2492
  });
2498
- return shareInfo.lib;
2493
+ return shareOptions.lib;
2499
2494
  }
2500
2495
  throw new Error(getShortErrorMsg(RUNTIME_006, runtimeDescMap, {
2501
2496
  hostName: host.options.name,
@@ -2548,6 +2543,12 @@ class SharedHandler {
2548
2543
  if (loading && !registeredShared.loading) {
2549
2544
  registeredShared.loading = loading;
2550
2545
  }
2546
+ if (loaded && !registeredShared.loaded) {
2547
+ registeredShared.loaded = loaded;
2548
+ }
2549
+ if (from && registeredShared.from !== from) {
2550
+ registeredShared.from = from;
2551
+ }
2551
2552
  });
2552
2553
  }
2553
2554
  _setGlobalShareScopeMap(hostOptions) {
@@ -3033,7 +3034,7 @@ class ModuleFederation {
3033
3034
  // maybe will change, temporarily for internal use only
3034
3035
  initContainer: new AsyncWaterfallHook('initContainer')
3035
3036
  });
3036
- this.version = "0.18.0";
3037
+ this.version = "0.18.2";
3037
3038
  this.moduleCache = new Map();
3038
3039
  this.loaderHook = new PluginSystem({
3039
3040
  // FIXME: may not be suitable , not open to the public yet
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/runtime-core",
3
- "version": "0.18.0",
3
+ "version": "0.18.2",
4
4
  "type": "module",
5
5
  "author": "zhouxiao <codingzx@gmail.com>",
6
6
  "main": "./dist/index.cjs.cjs",
@@ -52,7 +52,7 @@
52
52
  }
53
53
  },
54
54
  "dependencies": {
55
- "@module-federation/sdk": "0.18.0",
56
- "@module-federation/error-codes": "0.18.0"
55
+ "@module-federation/sdk": "0.18.2",
56
+ "@module-federation/error-codes": "0.18.2"
57
57
  }
58
58
  }