chayns-api 3.7.0-beta.0 → 3.7.0-beta.2

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.
@@ -17,35 +17,40 @@ const isManifestUrl = url => {
17
17
  return url.endsWith(MANIFEST_SUFFIX);
18
18
  }
19
19
  };
20
- const ManifestShareScopePlugin = () => ({
21
- name: 'manifest-share-scope',
22
- beforeRegisterRemote(args) {
23
- if ('entry' in args.remote && (args.remote.entry.endsWith('v2.remoteEntry.js') || isManifestUrl(args.remote.entry))) {
24
- Object.assign(args.remote, {
25
- shareScope: LEGACY_SHARE_SCOPE
20
+ const ManifestShareScopePlugin = () => {
21
+ const legacyRemotes = new WeakSet();
22
+ return {
23
+ name: 'manifest-share-scope',
24
+ beforeRegisterRemote(args) {
25
+ if (args.remote.shareScope) {
26
+ legacyRemotes.add(args.remote);
27
+ } else if ('entry' in args.remote && args.remote.entry.endsWith('v2.remoteEntry.js')) {
28
+ Object.assign(args.remote, {
29
+ shareScope: LEGACY_SHARE_SCOPE
30
+ });
31
+ }
32
+ return args;
33
+ },
34
+ async beforeRequest(args) {
35
+ var _manifest$metaData, _manifest$shared$find;
36
+ const remote = args.options.remotes.find(candidate => {
37
+ const name = candidate.name;
38
+ const alias = candidate.alias;
39
+ return args.id === name || args.id.startsWith(`${name}/`) || alias && (args.id === alias || args.id.startsWith(`${alias}/`));
26
40
  });
27
- }
28
- return args;
29
- },
30
- async beforeRequest(args) {
31
- var _manifest$metaData, _manifest$shared$find;
32
- const remote = args.options.remotes.find(candidate => {
33
- const name = candidate.name;
34
- const alias = candidate.alias;
35
- return args.id === name || args.id.startsWith(`${name}/`) || alias && (args.id === alias || args.id.startsWith(`${alias}/`));
36
- });
37
- if (!remote || !('entry' in remote) || !isManifestUrl(remote.entry)) {
41
+ if (!remote || legacyRemotes.has(remote) || !('entry' in remote) || !isManifestUrl(remote.entry)) {
42
+ return args;
43
+ }
44
+ await args.origin.snapshotHandler.loadRemoteSnapshotInfo({
45
+ moduleInfo: remote,
46
+ id: args.id
47
+ });
48
+ const manifest = args.origin.snapshotHandler.manifestCache.get(remote.entry);
49
+ const remoteShareScope = manifest === null || manifest === void 0 || (_manifest$metaData = manifest.metaData) === null || _manifest$metaData === void 0 ? void 0 : _manifest$metaData.reactShareScope;
50
+ const reactRequiredVersion = manifest === null || manifest === void 0 || (_manifest$shared$find = manifest.shared.find(shared => shared.name === 'react')) === null || _manifest$shared$find === void 0 ? void 0 : _manifest$shared$find.requiredVersion;
51
+ remote.shareScope = !remoteShareScope ? LEGACY_SHARE_SCOPE : reactRequiredVersion && (0, _runtimeCore.satisfy)(_react.default.version, reactRequiredVersion) ? `${HOST_REACT_SHARE_SCOPE}-${_react.default.version}` : remoteShareScope;
38
52
  return args;
39
53
  }
40
- await args.origin.snapshotHandler.loadRemoteSnapshotInfo({
41
- moduleInfo: remote,
42
- id: args.id
43
- });
44
- const manifest = args.origin.snapshotHandler.manifestCache.get(remote.entry);
45
- const remoteShareScope = manifest === null || manifest === void 0 || (_manifest$metaData = manifest.metaData) === null || _manifest$metaData === void 0 ? void 0 : _manifest$metaData.reactShareScope;
46
- const reactRequiredVersion = manifest === null || manifest === void 0 || (_manifest$shared$find = manifest.shared.find(shared => shared.name === 'react')) === null || _manifest$shared$find === void 0 ? void 0 : _manifest$shared$find.requiredVersion;
47
- remote.shareScope = !remoteShareScope ? LEGACY_SHARE_SCOPE : reactRequiredVersion && (0, _runtimeCore.satisfy)(_react.default.version, reactRequiredVersion) ? `${HOST_REACT_SHARE_SCOPE}-${_react.default.version}` : remoteShareScope;
48
- return args;
49
- }
50
- });
54
+ };
55
+ };
51
56
  exports.ManifestShareScopePlugin = ManifestShareScopePlugin;
@@ -13,6 +13,12 @@ var _injectExternalRuntimeCorePlugin = _interopRequireDefault(require("@module-f
13
13
  var _ManifestShareScopePlugin = require("../plugins/ManifestShareScopePlugin");
14
14
  var _SequentialLoadPlugin = require("../plugins/SequentialLoadPlugin");
15
15
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
+ let ReactCompilerRuntime;
17
+ try {
18
+ ReactCompilerRuntime = require('react/compiler-runtime');
19
+ } catch {
20
+ ReactCompilerRuntime = null;
21
+ }
16
22
  const ERROR_CACHE_TIME = 60000;
17
23
  const normalizeUrl = url => {
18
24
  try {
@@ -109,6 +115,13 @@ const initModuleFederationSharing = ({
109
115
  lib: () => _jsxRuntime.default
110
116
  }
111
117
  };
118
+ if (ReactCompilerRuntime) {
119
+ shared['react/compiler-runtime'] = {
120
+ version: _react.default.version,
121
+ scope: [`chayns-react-${_react.default.version}`, 'chayns-api'],
122
+ lib: () => ReactCompilerRuntime
123
+ };
124
+ }
112
125
  const instance = createInstance({
113
126
  name: (_ref = scope !== null && scope !== void 0 ? scope : name) !== null && _ref !== void 0 ? _ref : '',
114
127
  remotes: [],
@@ -10,34 +10,39 @@ const isManifestUrl = url => {
10
10
  return url.endsWith(MANIFEST_SUFFIX);
11
11
  }
12
12
  };
13
- export const ManifestShareScopePlugin = () => ({
14
- name: 'manifest-share-scope',
15
- beforeRegisterRemote(args) {
16
- if ('entry' in args.remote && (args.remote.entry.endsWith('v2.remoteEntry.js') || isManifestUrl(args.remote.entry))) {
17
- Object.assign(args.remote, {
18
- shareScope: LEGACY_SHARE_SCOPE
13
+ export const ManifestShareScopePlugin = () => {
14
+ const legacyRemotes = new WeakSet();
15
+ return {
16
+ name: 'manifest-share-scope',
17
+ beforeRegisterRemote(args) {
18
+ if (args.remote.shareScope) {
19
+ legacyRemotes.add(args.remote);
20
+ } else if ('entry' in args.remote && args.remote.entry.endsWith('v2.remoteEntry.js')) {
21
+ Object.assign(args.remote, {
22
+ shareScope: LEGACY_SHARE_SCOPE
23
+ });
24
+ }
25
+ return args;
26
+ },
27
+ async beforeRequest(args) {
28
+ var _manifest$metaData, _manifest$shared$find;
29
+ const remote = args.options.remotes.find(candidate => {
30
+ const name = candidate.name;
31
+ const alias = candidate.alias;
32
+ return args.id === name || args.id.startsWith(`${name}/`) || alias && (args.id === alias || args.id.startsWith(`${alias}/`));
19
33
  });
20
- }
21
- return args;
22
- },
23
- async beforeRequest(args) {
24
- var _manifest$metaData, _manifest$shared$find;
25
- const remote = args.options.remotes.find(candidate => {
26
- const name = candidate.name;
27
- const alias = candidate.alias;
28
- return args.id === name || args.id.startsWith(`${name}/`) || alias && (args.id === alias || args.id.startsWith(`${alias}/`));
29
- });
30
- if (!remote || !('entry' in remote) || !isManifestUrl(remote.entry)) {
34
+ if (!remote || legacyRemotes.has(remote) || !('entry' in remote) || !isManifestUrl(remote.entry)) {
35
+ return args;
36
+ }
37
+ await args.origin.snapshotHandler.loadRemoteSnapshotInfo({
38
+ moduleInfo: remote,
39
+ id: args.id
40
+ });
41
+ const manifest = args.origin.snapshotHandler.manifestCache.get(remote.entry);
42
+ const remoteShareScope = manifest === null || manifest === void 0 || (_manifest$metaData = manifest.metaData) === null || _manifest$metaData === void 0 ? void 0 : _manifest$metaData.reactShareScope;
43
+ const reactRequiredVersion = manifest === null || manifest === void 0 || (_manifest$shared$find = manifest.shared.find(shared => shared.name === 'react')) === null || _manifest$shared$find === void 0 ? void 0 : _manifest$shared$find.requiredVersion;
44
+ remote.shareScope = !remoteShareScope ? LEGACY_SHARE_SCOPE : reactRequiredVersion && satisfy(React.version, reactRequiredVersion) ? `${HOST_REACT_SHARE_SCOPE}-${React.version}` : remoteShareScope;
31
45
  return args;
32
46
  }
33
- await args.origin.snapshotHandler.loadRemoteSnapshotInfo({
34
- moduleInfo: remote,
35
- id: args.id
36
- });
37
- const manifest = args.origin.snapshotHandler.manifestCache.get(remote.entry);
38
- const remoteShareScope = manifest === null || manifest === void 0 || (_manifest$metaData = manifest.metaData) === null || _manifest$metaData === void 0 ? void 0 : _manifest$metaData.reactShareScope;
39
- const reactRequiredVersion = manifest === null || manifest === void 0 || (_manifest$shared$find = manifest.shared.find(shared => shared.name === 'react')) === null || _manifest$shared$find === void 0 ? void 0 : _manifest$shared$find.requiredVersion;
40
- remote.shareScope = !remoteShareScope ? LEGACY_SHARE_SCOPE : reactRequiredVersion && satisfy(React.version, reactRequiredVersion) ? `${HOST_REACT_SHARE_SCOPE}-${React.version}` : remoteShareScope;
41
- return args;
42
- }
43
- });
47
+ };
48
+ };
@@ -6,6 +6,12 @@ import ReactDOMServer from 'react-dom/server';
6
6
  import injectExternalRuntimeCodePlugin from '@module-federation/inject-external-runtime-core-plugin';
7
7
  import { ManifestShareScopePlugin } from '../plugins/ManifestShareScopePlugin';
8
8
  import { SequentialLoadPlugin } from '../plugins/SequentialLoadPlugin';
9
+ let ReactCompilerRuntime;
10
+ try {
11
+ ReactCompilerRuntime = require('react/compiler-runtime');
12
+ } catch {
13
+ ReactCompilerRuntime = null;
14
+ }
9
15
  const ERROR_CACHE_TIME = 60000;
10
16
  const normalizeUrl = url => {
11
17
  try {
@@ -102,6 +108,13 @@ export const initModuleFederationSharing = ({
102
108
  lib: () => JSXRuntime
103
109
  }
104
110
  };
111
+ if (ReactCompilerRuntime) {
112
+ shared['react/compiler-runtime'] = {
113
+ version: React.version,
114
+ scope: [`chayns-react-${React.version}`, 'chayns-api'],
115
+ lib: () => ReactCompilerRuntime
116
+ };
117
+ }
105
118
  const instance = createInstance({
106
119
  name: (_ref = scope !== null && scope !== void 0 ? scope : name) !== null && _ref !== void 0 ? _ref : '',
107
120
  remotes: [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chayns-api",
3
- "version": "3.7.0-beta.0",
3
+ "version": "3.7.0-beta.2",
4
4
  "description": "new chayns api",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",