chayns-api 1.2.0-6 → 1.2.0-8

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.
@@ -7,22 +7,22 @@ exports.loadModule = exports.default = void 0;
7
7
  var _semver = _interopRequireDefault(require("semver"));
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- const {
11
- loadRemote,
12
- registerRemotes,
13
- loadShareSync
14
- } = globalThis.moduleFederationRuntime;
15
- const {
16
- registeredScopes,
17
- moduleMap,
18
- componentMap
19
- } = globalThis.moduleFederationScopes;
20
10
  const loadModule = (scope, module, url, preventSingleton = false) => {
11
+ const {
12
+ loadRemote,
13
+ registerRemotes
14
+ } = globalThis.moduleFederationRuntime;
15
+ const {
16
+ registeredScopes,
17
+ moduleMap,
18
+ componentMap
19
+ } = globalThis.moduleFederationScopes;
21
20
  if (registeredScopes[scope] !== url || preventSingleton) {
22
21
  if (scope in registeredScopes) {
23
22
  console.error(`[chayns-api] call registerRemote with force for scope ${scope}. url: ${url}`);
24
23
  }
25
24
  registerRemotes([{
25
+ shareScope: 'chayns-api2',
26
26
  name: scope,
27
27
  entry: url,
28
28
  alias: scope
@@ -50,6 +50,12 @@ const loadComponent = (scope, module, url, skipCompatMode = false, preventSingle
50
50
  if (skipCompatMode) {
51
51
  console.warn('[chayns-api] skipCompatMode-option is deprecated and is set automatically now');
52
52
  }
53
+ const {
54
+ loadShareSync
55
+ } = globalThis.moduleFederationRuntime;
56
+ const {
57
+ componentMap
58
+ } = globalThis.moduleFederationScopes;
53
59
  if (!componentMap[scope]) {
54
60
  componentMap[scope] = {};
55
61
  }
@@ -67,6 +73,7 @@ const loadComponent = (scope, module, url, skipCompatMode = false, preventSingle
67
73
  loadShareSync('react', {
68
74
  resolver: shareOptions => {
69
75
  resolve(shareOptions);
76
+ console.log("shareOptions", shareOptions);
70
77
  return shareOptions[0];
71
78
  }
72
79
  });
@@ -29,12 +29,12 @@ const initModuleFederationSharing = () => {
29
29
  shared: {
30
30
  react: {
31
31
  version: _react.default.version,
32
- scope: 'default',
32
+ scope: 'chayns-api2',
33
33
  lib: () => _react.default
34
34
  },
35
35
  'react-dom': {
36
36
  version: _reactDom.default.version,
37
- scope: 'default',
37
+ scope: 'chayns-api2',
38
38
  lib: () => _reactDom.default
39
39
  }
40
40
  }
@@ -1,22 +1,22 @@
1
1
  import semver from 'semver';
2
2
  import React from "react";
3
- const {
4
- loadRemote,
5
- registerRemotes,
6
- loadShareSync
7
- } = globalThis.moduleFederationRuntime;
8
- const {
9
- registeredScopes,
10
- moduleMap,
11
- componentMap
12
- } = globalThis.moduleFederationScopes;
13
3
  export const loadModule = function (scope, module, url) {
14
4
  let preventSingleton = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
5
+ const {
6
+ loadRemote,
7
+ registerRemotes
8
+ } = globalThis.moduleFederationRuntime;
9
+ const {
10
+ registeredScopes,
11
+ moduleMap,
12
+ componentMap
13
+ } = globalThis.moduleFederationScopes;
15
14
  if (registeredScopes[scope] !== url || preventSingleton) {
16
15
  if (scope in registeredScopes) {
17
16
  console.error(`[chayns-api] call registerRemote with force for scope ${scope}. url: ${url}`);
18
17
  }
19
18
  registerRemotes([{
19
+ shareScope: 'chayns-api2',
20
20
  name: scope,
21
21
  entry: url,
22
22
  alias: scope
@@ -45,6 +45,12 @@ const loadComponent = function (scope, module, url) {
45
45
  if (skipCompatMode) {
46
46
  console.warn('[chayns-api] skipCompatMode-option is deprecated and is set automatically now');
47
47
  }
48
+ const {
49
+ loadShareSync
50
+ } = globalThis.moduleFederationRuntime;
51
+ const {
52
+ componentMap
53
+ } = globalThis.moduleFederationScopes;
48
54
  if (!componentMap[scope]) {
49
55
  componentMap[scope] = {};
50
56
  }
@@ -62,6 +68,7 @@ const loadComponent = function (scope, module, url) {
62
68
  loadShareSync('react', {
63
69
  resolver: shareOptions => {
64
70
  resolve(shareOptions);
71
+ console.log("shareOptions", shareOptions);
65
72
  return shareOptions[0];
66
73
  }
67
74
  });
@@ -22,12 +22,12 @@ export const initModuleFederationSharing = () => {
22
22
  shared: {
23
23
  react: {
24
24
  version: React.version,
25
- scope: 'default',
25
+ scope: 'chayns-api2',
26
26
  lib: () => React
27
27
  },
28
28
  'react-dom': {
29
29
  version: ReactDOM.version,
30
- scope: 'default',
30
+ scope: 'chayns-api2',
31
31
  lib: () => ReactDOM
32
32
  }
33
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chayns-api",
3
- "version": "1.2.0-6",
3
+ "version": "1.2.0-8",
4
4
  "description": "new chayns api",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",