chayns-api 2.1.0 → 2.1.1
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,6 +7,12 @@ exports.initModuleFederationSharing = void 0;
|
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
let ReactDOMClient;
|
|
11
|
+
try {
|
|
12
|
+
ReactDOMClient = require('react-dom/client');
|
|
13
|
+
} catch (e) {
|
|
14
|
+
// do nothing
|
|
15
|
+
}
|
|
10
16
|
const initModuleFederationSharing = ({
|
|
11
17
|
name
|
|
12
18
|
}) => {
|
|
@@ -23,22 +29,30 @@ const initModuleFederationSharing = ({
|
|
|
23
29
|
const {
|
|
24
30
|
init
|
|
25
31
|
} = globalThis.moduleFederationRuntime;
|
|
32
|
+
const shared = {
|
|
33
|
+
react: {
|
|
34
|
+
version: _react.default.version,
|
|
35
|
+
scope: 'chayns-api',
|
|
36
|
+
lib: () => _react.default
|
|
37
|
+
},
|
|
38
|
+
'react-dom': {
|
|
39
|
+
version: _react.default.version,
|
|
40
|
+
// intended, because react dom.version is not identical to package json react version (hash in version)
|
|
41
|
+
scope: 'chayns-api',
|
|
42
|
+
lib: () => _reactDom.default
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
if (ReactDOMClient) {
|
|
46
|
+
shared['react-dom/client'] = {
|
|
47
|
+
version: _react.default.version,
|
|
48
|
+
scope: 'chayns-api',
|
|
49
|
+
lib: () => ReactDOMClient
|
|
50
|
+
};
|
|
51
|
+
}
|
|
26
52
|
init({
|
|
27
53
|
name: name !== null && name !== void 0 ? name : '',
|
|
28
54
|
remotes: [],
|
|
29
|
-
shared
|
|
30
|
-
react: {
|
|
31
|
-
version: _react.default.version,
|
|
32
|
-
scope: 'chayns-api',
|
|
33
|
-
lib: () => _react.default
|
|
34
|
-
},
|
|
35
|
-
'react-dom': {
|
|
36
|
-
version: _react.default.version,
|
|
37
|
-
// intended, because react dom.version is not identical to package json react version (hash in version)
|
|
38
|
-
scope: 'chayns-api',
|
|
39
|
-
lib: () => _reactDom.default
|
|
40
|
-
}
|
|
41
|
-
}
|
|
55
|
+
shared
|
|
42
56
|
});
|
|
43
57
|
};
|
|
44
58
|
exports.initModuleFederationSharing = initModuleFederationSharing;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import ReactDOM from 'react-dom';
|
|
3
|
+
let ReactDOMClient;
|
|
4
|
+
try {
|
|
5
|
+
ReactDOMClient = require('react-dom/client');
|
|
6
|
+
} catch (e) {
|
|
7
|
+
// do nothing
|
|
8
|
+
}
|
|
3
9
|
export const initModuleFederationSharing = _ref => {
|
|
4
10
|
let {
|
|
5
11
|
name
|
|
@@ -17,21 +23,29 @@ export const initModuleFederationSharing = _ref => {
|
|
|
17
23
|
const {
|
|
18
24
|
init
|
|
19
25
|
} = globalThis.moduleFederationRuntime;
|
|
26
|
+
const shared = {
|
|
27
|
+
react: {
|
|
28
|
+
version: React.version,
|
|
29
|
+
scope: 'chayns-api',
|
|
30
|
+
lib: () => React
|
|
31
|
+
},
|
|
32
|
+
'react-dom': {
|
|
33
|
+
version: React.version,
|
|
34
|
+
// intended, because react dom.version is not identical to package json react version (hash in version)
|
|
35
|
+
scope: 'chayns-api',
|
|
36
|
+
lib: () => ReactDOM
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
if (ReactDOMClient) {
|
|
40
|
+
shared['react-dom/client'] = {
|
|
41
|
+
version: React.version,
|
|
42
|
+
scope: 'chayns-api',
|
|
43
|
+
lib: () => ReactDOMClient
|
|
44
|
+
};
|
|
45
|
+
}
|
|
20
46
|
init({
|
|
21
47
|
name: name !== null && name !== void 0 ? name : '',
|
|
22
48
|
remotes: [],
|
|
23
|
-
shared
|
|
24
|
-
react: {
|
|
25
|
-
version: React.version,
|
|
26
|
-
scope: 'chayns-api',
|
|
27
|
-
lib: () => React
|
|
28
|
-
},
|
|
29
|
-
'react-dom': {
|
|
30
|
-
version: React.version,
|
|
31
|
-
// intended, because react dom.version is not identical to package json react version (hash in version)
|
|
32
|
-
scope: 'chayns-api',
|
|
33
|
-
lib: () => ReactDOM
|
|
34
|
-
}
|
|
35
|
-
}
|
|
49
|
+
shared
|
|
36
50
|
});
|
|
37
51
|
};
|