chayns-api 2.6.0-beta.3 → 2.6.0-beta.5

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.
@@ -58,7 +58,7 @@ const loadComponent = (scope, module, url, skipCompatMode = false, preventSingle
58
58
  throw new Error('[chayns-api] moduleFederationSharing has not been initialized. Make sure to call initModuleFederationSharing.');
59
59
  }
60
60
  const {
61
- getInstance
61
+ shareScopeMap: shareScopes
62
62
  } = globalThis.moduleFederationRuntime;
63
63
  const {
64
64
  componentMap,
@@ -73,7 +73,6 @@ const loadComponent = (scope, module, url, skipCompatMode = false, preventSingle
73
73
  if (typeof Module.default === 'function') {
74
74
  return Module;
75
75
  }
76
- const shareScopes = getInstance().shareScopeMap;
77
76
  const sharedReact = (_shareScopes$chaynsA = shareScopes['chayns-api'].react) === null || _shareScopes$chaynsA === void 0 ? void 0 : _shareScopes$chaynsA[_react.default.version];
78
77
  const matchReactVersion = sharedReact && sharedReact.useIn.includes(scope) && ((_sharedReact$lib = sharedReact.lib) === null || _sharedReact$lib === void 0 ? void 0 : _sharedReact$lib.call(sharedReact)) === _react.default;
79
78
  if (!matchReactVersion || Module.default.environment !== 'production' || (Module.default.version || 1) < 2) {
@@ -16,18 +16,12 @@ const initModuleFederationSharing = ({
16
16
  name,
17
17
  plugins = []
18
18
  }) => {
19
- if (globalThis.moduleFederationRuntime) {
19
+ if (globalThis.moduleFederationScopes) {
20
20
  return;
21
21
  }
22
- globalThis.moduleFederationRuntime = require('@module-federation/enhanced/runtime');
23
- globalThis.moduleFederationScopes = {
24
- registeredScopes: {},
25
- moduleMap: {},
26
- componentMap: {}
27
- };
28
22
  const {
29
23
  createInstance
30
- } = globalThis.moduleFederationRuntime;
24
+ } = require('@module-federation/enhanced/runtime');
31
25
  const shared = {
32
26
  react: {
33
27
  version: _react.default.version,
@@ -47,11 +41,16 @@ const initModuleFederationSharing = ({
47
41
  lib: () => ReactDOMClient
48
42
  };
49
43
  }
50
- createInstance({
44
+ globalThis.moduleFederationRuntime = createInstance({
51
45
  name: name !== null && name !== void 0 ? name : '',
52
46
  remotes: [],
53
47
  shared,
54
48
  plugins: [(0, _SequentialLoadPlugin.SequentialLoadPlugin)(), ...plugins]
55
49
  });
50
+ globalThis.moduleFederationScopes = {
51
+ registeredScopes: {},
52
+ moduleMap: {},
53
+ componentMap: {}
54
+ };
56
55
  };
57
56
  exports.initModuleFederationSharing = initModuleFederationSharing;
@@ -50,7 +50,7 @@ const loadComponent = (scope, module, url, skipCompatMode = false, preventSingle
50
50
  throw new Error('[chayns-api] moduleFederationSharing has not been initialized. Make sure to call initModuleFederationSharing.');
51
51
  }
52
52
  const {
53
- getInstance
53
+ shareScopeMap: shareScopes
54
54
  } = globalThis.moduleFederationRuntime;
55
55
  const {
56
56
  componentMap,
@@ -65,7 +65,6 @@ const loadComponent = (scope, module, url, skipCompatMode = false, preventSingle
65
65
  if (typeof Module.default === 'function') {
66
66
  return Module;
67
67
  }
68
- const shareScopes = getInstance().shareScopeMap;
69
68
  const sharedReact = (_shareScopes$chaynsA = shareScopes['chayns-api'].react) === null || _shareScopes$chaynsA === void 0 ? void 0 : _shareScopes$chaynsA[React.version];
70
69
  const matchReactVersion = sharedReact && sharedReact.useIn.includes(scope) && ((_sharedReact$lib = sharedReact.lib) === null || _sharedReact$lib === void 0 ? void 0 : _sharedReact$lib.call(sharedReact)) === React;
71
70
  if (!matchReactVersion || Module.default.environment !== 'production' || (Module.default.version || 1) < 2) {
@@ -9,18 +9,12 @@ export const initModuleFederationSharing = ({
9
9
  name,
10
10
  plugins = []
11
11
  }) => {
12
- if (globalThis.moduleFederationRuntime) {
12
+ if (globalThis.moduleFederationScopes) {
13
13
  return;
14
14
  }
15
- globalThis.moduleFederationRuntime = require('@module-federation/enhanced/runtime');
16
- globalThis.moduleFederationScopes = {
17
- registeredScopes: {},
18
- moduleMap: {},
19
- componentMap: {}
20
- };
21
15
  const {
22
16
  createInstance
23
- } = globalThis.moduleFederationRuntime;
17
+ } = require('@module-federation/enhanced/runtime');
24
18
  const shared = {
25
19
  react: {
26
20
  version: React.version,
@@ -40,10 +34,15 @@ export const initModuleFederationSharing = ({
40
34
  lib: () => ReactDOMClient
41
35
  };
42
36
  }
43
- createInstance({
37
+ globalThis.moduleFederationRuntime = createInstance({
44
38
  name: name !== null && name !== void 0 ? name : '',
45
39
  remotes: [],
46
40
  shared,
47
41
  plugins: [SequentialLoadPlugin(), ...plugins]
48
42
  });
43
+ globalThis.moduleFederationScopes = {
44
+ registeredScopes: {},
45
+ moduleMap: {},
46
+ componentMap: {}
47
+ };
49
48
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chayns-api",
3
- "version": "2.6.0-beta.3",
3
+ "version": "2.6.0-beta.5",
4
4
  "description": "new chayns api",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",