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.
- package/dist/cjs/components/withCompatMode.js +1 -2
- package/dist/cjs/host/module/utils/loadComponent.js +7 -11
- package/dist/esm/components/withCompatMode.js +1 -2
- package/dist/esm/host/module/utils/loadComponent.js +7 -11
- package/dist/types/components/withCompatMode.d.ts +0 -1
- package/dist/types/host/module/utils/loadComponent.d.ts +1 -1
- package/package.json +1 -1
|
@@ -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: '
|
|
23
|
+
scope: 'default',
|
|
24
24
|
lib: () => _react.default
|
|
25
25
|
},
|
|
26
26
|
'react-dom': {
|
|
27
27
|
version: _reactDom.default.version,
|
|
28
|
-
scope: '
|
|
28
|
+
scope: 'default',
|
|
29
29
|
lib: () => _reactDom.default
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
|
-
const loadModule =
|
|
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 (
|
|
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: '
|
|
16
|
+
scope: 'default',
|
|
17
17
|
lib: () => React
|
|
18
18
|
},
|
|
19
19
|
'react-dom': {
|
|
20
20
|
version: ReactDOM.version,
|
|
21
|
-
scope: '
|
|
21
|
+
scope: 'default',
|
|
22
22
|
lib: () => ReactDOM
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
|
-
export const loadModule =
|
|
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 (
|
|
89
|
+
if (!matchReactVersion || environment !== 'production' || process.env.NODE_ENV === 'development') {
|
|
94
90
|
return {
|
|
95
91
|
default: Module.default.CompatComponent
|
|
96
92
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const loadModule: (scope: any, module: any, url: any, preventSingleton?: boolean) =>
|
|
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;
|