chayns-api 2.4.30 → 2.5.0-beta.0

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.
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SequentialLoadPlugin = void 0;
7
+ const SequentialLoadPlugin = () => {
8
+ return {
9
+ name: 'sequential-load',
10
+ async beforeInitContainer(args) {
11
+ const manifest = args.origin.snapshotHandler.manifestCache.get(args.remoteEntryInitOptions.version);
12
+ const requiredShares = new Set(manifest === null || manifest === void 0 ? void 0 : manifest.shared.map(share => share.name));
13
+ for (const [key, pkg] of Object.entries(args.shareScope)) {
14
+ if (manifest && !requiredShares.has(key)) {
15
+ continue;
16
+ }
17
+ for (const version of Object.values(pkg)) {
18
+ if (!version.loaded && version.loading) {
19
+ await version.loading;
20
+ }
21
+ }
22
+ }
23
+ return args;
24
+ }
25
+ };
26
+ };
27
+ exports.SequentialLoadPlugin = SequentialLoadPlugin;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.initModuleFederationSharing = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _reactDom = _interopRequireDefault(require("react-dom"));
9
+ var _SequentialLoadPlugin = require("../plugins/SequentialLoadPlugin");
9
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
11
  let ReactDOMClient;
11
12
  try {
@@ -48,7 +49,8 @@ const initModuleFederationSharing = ({
48
49
  init({
49
50
  name: name !== null && name !== void 0 ? name : '',
50
51
  remotes: [],
51
- shared
52
+ shared,
53
+ plugins: [(0, _SequentialLoadPlugin.SequentialLoadPlugin)()]
52
54
  });
53
55
  };
54
56
  exports.initModuleFederationSharing = initModuleFederationSharing;
@@ -0,0 +1,20 @@
1
+ export const SequentialLoadPlugin = () => {
2
+ return {
3
+ name: 'sequential-load',
4
+ async beforeInitContainer(args) {
5
+ const manifest = args.origin.snapshotHandler.manifestCache.get(args.remoteEntryInitOptions.version);
6
+ const requiredShares = new Set(manifest === null || manifest === void 0 ? void 0 : manifest.shared.map(share => share.name));
7
+ for (const [key, pkg] of Object.entries(args.shareScope)) {
8
+ if (manifest && !requiredShares.has(key)) {
9
+ continue;
10
+ }
11
+ for (const version of Object.values(pkg)) {
12
+ if (!version.loaded && version.loading) {
13
+ await version.loading;
14
+ }
15
+ }
16
+ }
17
+ return args;
18
+ }
19
+ };
20
+ };
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import ReactDOM from 'react-dom';
3
+ import { SequentialLoadPlugin } from '../plugins/SequentialLoadPlugin';
3
4
  let ReactDOMClient;
4
5
  try {
5
6
  ReactDOMClient = require('react-dom/client');
@@ -42,6 +43,7 @@ export const initModuleFederationSharing = _ref => {
42
43
  init({
43
44
  name: name !== null && name !== void 0 ? name : '',
44
45
  remotes: [],
45
- shared
46
+ shared,
47
+ plugins: [SequentialLoadPlugin()]
46
48
  });
47
49
  };
@@ -0,0 +1,5 @@
1
+ import type { FederationRuntimePlugin } from '@module-federation/enhanced/runtime';
2
+ /**
3
+ * Plugin to prevent parallel loading of shared dependencies
4
+ */
5
+ export declare const SequentialLoadPlugin: () => FederationRuntimePlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chayns-api",
3
- "version": "2.4.30",
3
+ "version": "2.5.0-beta.0",
4
4
  "description": "new chayns api",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",