chayns-api 1.1.0-29 → 1.1.0-30

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.
@@ -75,8 +75,7 @@ const withCompatMode = Component => {
75
75
  requiredVersion: __REQUIRED_REACT_VERSION__,
76
76
  environment: process.env.NODE_ENV,
77
77
  buildEnv: process.env.BUILD_ENV || process.env.NODE_ENV,
78
- appVersion: process.env.VERSION,
79
- version: 2
78
+ appVersion: process.env.VERSION
80
79
  };
81
80
  };
82
81
  exports.withCompatMode = withCompatMode;
@@ -20,17 +20,17 @@ const componentMap = {};
20
20
  shared: {
21
21
  react: {
22
22
  version: _react.default.version,
23
- scope: 'defaultV2',
23
+ scope: 'default',
24
24
  lib: () => _react.default
25
25
  },
26
26
  'react-dom': {
27
27
  version: _reactDom.default.version,
28
- scope: 'defaultV2',
28
+ scope: 'default',
29
29
  lib: () => _reactDom.default
30
30
  }
31
31
  }
32
32
  });
33
- const loadModule = async (scope, module, url, preventSingleton = false) => {
33
+ const loadModule = (scope, module, url, preventSingleton = false) => {
34
34
  if (registeredScopes[scope] !== url || preventSingleton) {
35
35
  if (scope in registeredScopes) {
36
36
  console.error(`[chayns-api] call registerRemote with force for scope ${scope}. url: ${url}`);
@@ -38,10 +38,9 @@ const loadModule = async (scope, module, url, preventSingleton = false) => {
38
38
  (0, _runtime.registerRemotes)([{
39
39
  name: scope,
40
40
  entry: url,
41
- alias: scope,
42
- shareScope: 'defaultV2'
41
+ alias: scope
43
42
  }], {
44
- force: scope in registeredScopes
43
+ force: scope in registeredScopes || preventSingleton
45
44
  });
46
45
  registeredScopes[scope] = url;
47
46
  moduleMap[scope] = {};
@@ -49,9 +48,7 @@ const loadModule = async (scope, module, url, preventSingleton = false) => {
49
48
  }
50
49
  if (!(module in moduleMap[scope])) {
51
50
  const path = `${scope}/${module.replace(/^\.\//, '')}`;
52
- const promise = (0, _runtime.loadRemote)(path, {
53
- from: 'runtime'
54
- });
51
+ const promise = (0, _runtime.loadRemote)(path);
55
52
  promise.catch(e => {
56
53
  console.error("[chayns-api] Failed to load module", scope, url, e);
57
54
  // causes registerRemote with force = true on next attempt to load the component which tries to load the component again
@@ -83,7 +80,6 @@ const loadComponent = (scope, module, url, skipCompatMode = false, preventSingle
83
80
  (0, _runtime.loadShareSync)('react', {
84
81
  resolver: shareOptions => {
85
82
  resolve(shareOptions);
86
- console.log('mf runtime share scopes', shareOptions);
87
83
  return shareOptions[0];
88
84
  }
89
85
  });
@@ -94,7 +90,7 @@ const loadComponent = (scope, module, url, skipCompatMode = false, preventSingle
94
90
  }) => {
95
91
  return _semver.default.gt(version, hostVersion) && _semver.default.satisfies(version, requiredVersion) || scope === from.split('-').join('_');
96
92
  });
97
- if (Module.default.version !== 2 || !matchReactVersion || environment !== 'production' || process.env.NODE_ENV === 'development') {
93
+ if (!matchReactVersion || environment !== 'production' || process.env.NODE_ENV === 'development') {
98
94
  return {
99
95
  default: Module.default.CompatComponent
100
96
  };
@@ -68,7 +68,6 @@ export const withCompatMode = Component => {
68
68
  requiredVersion: __REQUIRED_REACT_VERSION__,
69
69
  environment: process.env.NODE_ENV,
70
70
  buildEnv: process.env.BUILD_ENV || process.env.NODE_ENV,
71
- appVersion: process.env.VERSION,
72
- version: 2
71
+ appVersion: process.env.VERSION
73
72
  };
74
73
  };
@@ -13,17 +13,17 @@ init({
13
13
  shared: {
14
14
  react: {
15
15
  version: React.version,
16
- scope: 'defaultV2',
16
+ scope: 'default',
17
17
  lib: () => React
18
18
  },
19
19
  'react-dom': {
20
20
  version: ReactDOM.version,
21
- scope: 'defaultV2',
21
+ scope: 'default',
22
22
  lib: () => ReactDOM
23
23
  }
24
24
  }
25
25
  });
26
- export const loadModule = async function (scope, module, url) {
26
+ export const loadModule = function (scope, module, url) {
27
27
  let preventSingleton = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
28
28
  if (registeredScopes[scope] !== url || preventSingleton) {
29
29
  if (scope in registeredScopes) {
@@ -32,10 +32,9 @@ export const loadModule = async function (scope, module, url) {
32
32
  registerRemotes([{
33
33
  name: scope,
34
34
  entry: url,
35
- alias: scope,
36
- shareScope: 'defaultV2'
35
+ alias: scope
37
36
  }], {
38
- force: scope in registeredScopes
37
+ force: scope in registeredScopes || preventSingleton
39
38
  });
40
39
  registeredScopes[scope] = url;
41
40
  moduleMap[scope] = {};
@@ -43,9 +42,7 @@ export const loadModule = async function (scope, module, url) {
43
42
  }
44
43
  if (!(module in moduleMap[scope])) {
45
44
  const path = `${scope}/${module.replace(/^\.\//, '')}`;
46
- const promise = loadRemote(path, {
47
- from: 'runtime'
48
- });
45
+ const promise = loadRemote(path);
49
46
  promise.catch(e => {
50
47
  console.error("[chayns-api] Failed to load module", scope, url, e);
51
48
  // causes registerRemote with force = true on next attempt to load the component which tries to load the component again
@@ -78,7 +75,6 @@ const loadComponent = function (scope, module, url) {
78
75
  loadShareSync('react', {
79
76
  resolver: shareOptions => {
80
77
  resolve(shareOptions);
81
- console.log('mf runtime share scopes', shareOptions);
82
78
  return shareOptions[0];
83
79
  }
84
80
  });
@@ -90,7 +86,7 @@ const loadComponent = function (scope, module, url) {
90
86
  } = _ref;
91
87
  return semver.gt(version, hostVersion) && semver.satisfies(version, requiredVersion) || scope === from.split('-').join('_');
92
88
  });
93
- if (Module.default.version !== 2 || !matchReactVersion || environment !== 'production' || process.env.NODE_ENV === 'development') {
89
+ if (!matchReactVersion || environment !== 'production' || process.env.NODE_ENV === 'development') {
94
90
  return {
95
91
  default: Module.default.CompatComponent
96
92
  };
@@ -9,6 +9,5 @@ export declare const withCompatMode: <P extends Props>(Component: React.Componen
9
9
  environment: string | undefined;
10
10
  buildEnv: string | undefined;
11
11
  appVersion: string | undefined;
12
- version: number;
13
12
  };
14
13
  export {};
@@ -1,3 +1,3 @@
1
- export declare const loadModule: (scope: any, module: any, url: any, preventSingleton?: boolean) => Promise<any>;
1
+ export declare const loadModule: (scope: any, module: any, url: any, preventSingleton?: boolean) => any;
2
2
  declare const loadComponent: (scope: any, module: any, url: any, skipCompatMode?: boolean, preventSingleton?: boolean) => any;
3
3
  export default loadComponent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chayns-api",
3
- "version": "1.1.0-29",
3
+ "version": "1.1.0-30",
4
4
  "description": "new chayns api",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",