@module-federation/runtime 0.0.0-next-20240122061426 → 0.0.0-next-20240122073529

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.cjs.js CHANGED
@@ -1324,7 +1324,7 @@ class FederationHost {
1324
1324
  const { module, moduleOptions, remoteMatchInfo } = await this._getRemoteModuleAndOptions(id);
1325
1325
  const { pkgNameOrAlias, remote, expose, id: idRes } = remoteMatchInfo;
1326
1326
  const moduleOrFactory = await module.get(expose, options);
1327
- await this.hooks.lifecycle.onLoad.emit({
1327
+ const moduleWrapper = await this.hooks.lifecycle.onLoad.emit({
1328
1328
  id: idRes,
1329
1329
  pkgNameOrAlias,
1330
1330
  expose,
@@ -1335,6 +1335,9 @@ class FederationHost {
1335
1335
  moduleInstance: module,
1336
1336
  origin: this
1337
1337
  });
1338
+ if (typeof moduleWrapper === 'function') {
1339
+ return moduleWrapper;
1340
+ }
1338
1341
  return moduleOrFactory;
1339
1342
  } catch (error) {
1340
1343
  const { from = 'runtime' } = options || {
@@ -1461,7 +1464,7 @@ class FederationHost {
1461
1464
  }
1462
1465
  // Set the remote entry to a complete path
1463
1466
  if ('entry' in remote) {
1464
- if (share.isBrowserEnv()) {
1467
+ if (share.isBrowserEnv() && !remote.entry.startsWith('http')) {
1465
1468
  remote.entry = new URL(remote.entry, window.location.origin).href;
1466
1469
  }
1467
1470
  }
@@ -1576,7 +1579,7 @@ class FederationHost {
1576
1579
  // not used yet
1577
1580
  afterPreloadRemote: new AsyncHook()
1578
1581
  });
1579
- this.version = "0.0.8";
1582
+ this.version = "0.0.9";
1580
1583
  this.moduleCache = new Map();
1581
1584
  this.loaderHook = new PluginSystem({
1582
1585
  // FIXME: may not be suitable , not open to the public yet
package/dist/index.esm.js CHANGED
@@ -1322,7 +1322,7 @@ class FederationHost {
1322
1322
  const { module, moduleOptions, remoteMatchInfo } = await this._getRemoteModuleAndOptions(id);
1323
1323
  const { pkgNameOrAlias, remote, expose, id: idRes } = remoteMatchInfo;
1324
1324
  const moduleOrFactory = await module.get(expose, options);
1325
- await this.hooks.lifecycle.onLoad.emit({
1325
+ const moduleWrapper = await this.hooks.lifecycle.onLoad.emit({
1326
1326
  id: idRes,
1327
1327
  pkgNameOrAlias,
1328
1328
  expose,
@@ -1333,6 +1333,9 @@ class FederationHost {
1333
1333
  moduleInstance: module,
1334
1334
  origin: this
1335
1335
  });
1336
+ if (typeof moduleWrapper === 'function') {
1337
+ return moduleWrapper;
1338
+ }
1336
1339
  return moduleOrFactory;
1337
1340
  } catch (error) {
1338
1341
  const { from = 'runtime' } = options || {
@@ -1459,7 +1462,7 @@ class FederationHost {
1459
1462
  }
1460
1463
  // Set the remote entry to a complete path
1461
1464
  if ('entry' in remote) {
1462
- if (isBrowserEnv()) {
1465
+ if (isBrowserEnv() && !remote.entry.startsWith('http')) {
1463
1466
  remote.entry = new URL(remote.entry, window.location.origin).href;
1464
1467
  }
1465
1468
  }
@@ -1574,7 +1577,7 @@ class FederationHost {
1574
1577
  // not used yet
1575
1578
  afterPreloadRemote: new AsyncHook()
1576
1579
  });
1577
- this.version = "0.0.8";
1580
+ this.version = "0.0.9";
1578
1581
  this.moduleCache = new Map();
1579
1582
  this.loaderHook = new PluginSystem({
1580
1583
  // FIXME: may not be suitable , not open to the public yet
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/runtime",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "author": "zhouxiao <codingzx@gmail.com>",
5
5
  "main": "./index.cjs.js",
6
6
  "module": "./index.esm.js",
package/dist/share.cjs.js CHANGED
@@ -171,7 +171,7 @@ function getGlobalFederationConstructor() {
171
171
  function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
172
172
  if (isDebug) {
173
173
  globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
174
- globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.8";
174
+ globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.9";
175
175
  }
176
176
  }
177
177
  // eslint-disable-next-line @typescript-eslint/ban-types
@@ -702,24 +702,27 @@ const findVersion = (shareScopeMap, scope, pkgName, cb)=>{
702
702
  return prev;
703
703
  }, 0);
704
704
  };
705
+ const isLoaded = (shared)=>{
706
+ return Boolean(shared.loaded) || typeof shared.lib === 'function';
707
+ };
705
708
  function findSingletonVersionOrderByVersion(shareScopeMap, scope, pkgName) {
706
709
  const versions = shareScopeMap[scope][pkgName];
707
710
  const callback = function(prev, cur) {
708
- return !versions[prev].loaded && versionLt(prev, cur);
711
+ return !isLoaded(versions[prev]) && versionLt(prev, cur);
709
712
  };
710
713
  return findVersion(shareScopeMap, scope, pkgName, callback);
711
714
  }
712
715
  function findSingletonVersionOrderByLoaded(shareScopeMap, scope, pkgName) {
713
716
  const versions = shareScopeMap[scope][pkgName];
714
717
  const callback = function(prev, cur) {
715
- if (versions[cur].loaded) {
716
- if (versions[prev].loaded) {
718
+ if (isLoaded(versions[cur])) {
719
+ if (isLoaded(versions[prev])) {
717
720
  return Boolean(versionLt(prev, cur));
718
721
  } else {
719
722
  return true;
720
723
  }
721
724
  }
722
- if (versions[prev].loaded) {
725
+ if (isLoaded(versions[prev])) {
723
726
  return false;
724
727
  }
725
728
  return versionLt(prev, cur);
package/dist/share.esm.js CHANGED
@@ -169,7 +169,7 @@ function getGlobalFederationConstructor() {
169
169
  function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
170
170
  if (isDebug) {
171
171
  globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
172
- globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.8";
172
+ globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.9";
173
173
  }
174
174
  }
175
175
  // eslint-disable-next-line @typescript-eslint/ban-types
@@ -700,24 +700,27 @@ const findVersion = (shareScopeMap, scope, pkgName, cb)=>{
700
700
  return prev;
701
701
  }, 0);
702
702
  };
703
+ const isLoaded = (shared)=>{
704
+ return Boolean(shared.loaded) || typeof shared.lib === 'function';
705
+ };
703
706
  function findSingletonVersionOrderByVersion(shareScopeMap, scope, pkgName) {
704
707
  const versions = shareScopeMap[scope][pkgName];
705
708
  const callback = function(prev, cur) {
706
- return !versions[prev].loaded && versionLt(prev, cur);
709
+ return !isLoaded(versions[prev]) && versionLt(prev, cur);
707
710
  };
708
711
  return findVersion(shareScopeMap, scope, pkgName, callback);
709
712
  }
710
713
  function findSingletonVersionOrderByLoaded(shareScopeMap, scope, pkgName) {
711
714
  const versions = shareScopeMap[scope][pkgName];
712
715
  const callback = function(prev, cur) {
713
- if (versions[cur].loaded) {
714
- if (versions[prev].loaded) {
716
+ if (isLoaded(versions[cur])) {
717
+ if (isLoaded(versions[prev])) {
715
718
  return Boolean(versionLt(prev, cur));
716
719
  } else {
717
720
  return true;
718
721
  }
719
722
  }
720
- if (versions[prev].loaded) {
723
+ if (isLoaded(versions[prev])) {
721
724
  return false;
722
725
  }
723
726
  return versionLt(prev, cur);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/runtime",
3
- "version": "0.0.0-next-20240122061426",
3
+ "version": "0.0.0-next-20240122073529",
4
4
  "author": "zhouxiao <codingzx@gmail.com>",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.esm.js",
@@ -45,6 +45,6 @@
45
45
  }
46
46
  },
47
47
  "dependencies": {
48
- "@module-federation/sdk": "0.0.0-next-20240122061426"
48
+ "@module-federation/sdk": "0.0.0-next-20240122073529"
49
49
  }
50
50
  }