@module-federation/data-prefetch 0.0.0-next-20240927195332 → 0.0.0-next-20240930091801

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.
Files changed (77) hide show
  1. package/CHANGELOG.md +4 -3
  2. package/LICENSE +1 -1
  3. package/dist/{src/cli → cli}/babel.d.ts +4 -2
  4. package/dist/cli/babel.js +84 -0
  5. package/dist/{src/cli → cli}/index.d.ts +8 -5
  6. package/dist/cli/index.js +207 -0
  7. package/dist/esm/chunk-AJPO2B2T.js +30 -0
  8. package/dist/esm/chunk-BGNOVRH5.js +166 -0
  9. package/dist/esm/chunk-EZUCZHGV.js +11 -0
  10. package/dist/esm/chunk-ISF7VMBW.js +156 -0
  11. package/dist/esm/chunk-OCDMSRMZ.js +32 -0
  12. package/dist/esm/chunk-TTJJJ2WZ.js +7 -0
  13. package/dist/esm/cli/babel.js +57 -0
  14. package/dist/esm/cli/index.js +180 -0
  15. package/dist/esm/index.js +13 -0
  16. package/dist/esm/plugin.js +12 -0
  17. package/dist/esm/react/index.js +94 -0
  18. package/dist/esm/shared/index.js +27 -0
  19. package/dist/esm/universal/index.js +9 -0
  20. package/dist/index.d.ts +5 -0
  21. package/dist/index.js +351 -0
  22. package/dist/plugin.d.ts +5 -0
  23. package/dist/plugin.js +347 -0
  24. package/dist/{src/prefetch.d.ts → prefetch-c08be471.d.ts} +6 -4
  25. package/dist/react/index.d.ts +16 -0
  26. package/dist/react/index.js +287 -0
  27. package/dist/shared/index.d.ts +5 -0
  28. package/dist/shared/index.js +48 -0
  29. package/dist/universal/index.d.ts +8 -0
  30. package/dist/universal/index.js +205 -0
  31. package/package.json +28 -31
  32. package/project.json +4 -46
  33. package/src/cli/index.ts +2 -2
  34. package/tsconfig.json +1 -1
  35. package/dist/LICENSE +0 -21
  36. package/dist/babel.cjs.d.ts +0 -2
  37. package/dist/babel.cjs.js +0 -62
  38. package/dist/babel.esm.js +0 -56
  39. package/dist/cli.cjs.d.ts +0 -1
  40. package/dist/cli.cjs.js +0 -3579
  41. package/dist/cli.esm.js +0 -3565
  42. package/dist/index.cjs.d.ts +0 -1
  43. package/dist/index.cjs.js +0 -15
  44. package/dist/index.cjs2.js +0 -7
  45. package/dist/index.esm.js +0 -6
  46. package/dist/index.esm2.js +0 -5
  47. package/dist/package.json +0 -99
  48. package/dist/plugin.cjs.d.ts +0 -2
  49. package/dist/plugin.cjs.js +0 -362
  50. package/dist/plugin.esm.js +0 -357
  51. package/dist/prefetch.cjs.js +0 -351
  52. package/dist/prefetch.esm.js +0 -349
  53. package/dist/react.cjs.d.ts +0 -1
  54. package/dist/react.cjs.js +0 -163
  55. package/dist/react.esm.js +0 -159
  56. package/dist/runtime-utils.cjs.js +0 -31
  57. package/dist/runtime-utils.esm.js +0 -26
  58. package/dist/shared.cjs.d.ts +0 -2
  59. package/dist/shared.cjs.js +0 -26
  60. package/dist/shared.esm.js +0 -24
  61. package/dist/src/common/constant.d.ts +0 -1
  62. package/dist/src/common/index.d.ts +0 -1
  63. package/dist/src/common/node-utils.d.ts +0 -2
  64. package/dist/src/common/runtime-utils.d.ts +0 -5
  65. package/dist/src/index.d.ts +0 -2
  66. package/dist/src/logger/index.d.ts +0 -3
  67. package/dist/src/plugin.d.ts +0 -3
  68. package/dist/src/react/hooks.d.ts +0 -11
  69. package/dist/src/react/index.d.ts +0 -1
  70. package/dist/src/react/utils.d.ts +0 -1
  71. package/dist/src/shared/index.d.ts +0 -3
  72. package/dist/src/universal/index.d.ts +0 -2
  73. package/dist/universal.cjs.d.ts +0 -1
  74. package/dist/universal.cjs.js +0 -38
  75. package/dist/universal.esm.js +0 -34
  76. package/rollup.config.js +0 -25
  77. package/tsconfig.lib.json +0 -10
package/dist/react.cjs.js DELETED
@@ -1,163 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var react = require('react');
6
- var index = require('./index.cjs2.js');
7
- var prefetch = require('./prefetch.cjs.js');
8
- var universal = require('./universal.cjs.js');
9
- var runtimeUtils = require('./runtime-utils.cjs.js');
10
- require('@module-federation/sdk');
11
- require('@module-federation/runtime');
12
-
13
- var useFirstMounted = function() {
14
- var ref = react.useRef(true);
15
- react.useEffect(function() {
16
- ref.current = false;
17
- }, []);
18
- return ref.current;
19
- };
20
-
21
- function _array_like_to_array(arr, len) {
22
- if (len == null || len > arr.length) len = arr.length;
23
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
24
- return arr2;
25
- }
26
- function _array_with_holes(arr) {
27
- if (Array.isArray(arr)) return arr;
28
- }
29
- function _define_property(obj, key, value) {
30
- if (key in obj) {
31
- Object.defineProperty(obj, key, {
32
- value: value,
33
- enumerable: true,
34
- configurable: true,
35
- writable: true
36
- });
37
- } else {
38
- obj[key] = value;
39
- }
40
- return obj;
41
- }
42
- function _instanceof(left, right) {
43
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
44
- return !!right[Symbol.hasInstance](left);
45
- } else {
46
- return left instanceof right;
47
- }
48
- }
49
- function _iterable_to_array_limit(arr, i) {
50
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
51
- if (_i == null) return;
52
- var _arr = [];
53
- var _n = true;
54
- var _d = false;
55
- var _s, _e;
56
- try {
57
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
58
- _arr.push(_s.value);
59
- if (i && _arr.length === i) break;
60
- }
61
- } catch (err) {
62
- _d = true;
63
- _e = err;
64
- } finally{
65
- try {
66
- if (!_n && _i["return"] != null) _i["return"]();
67
- } finally{
68
- if (_d) throw _e;
69
- }
70
- }
71
- return _arr;
72
- }
73
- function _non_iterable_rest() {
74
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
75
- }
76
- function _object_spread(target) {
77
- for(var i = 1; i < arguments.length; i++){
78
- var source = arguments[i] != null ? arguments[i] : {};
79
- var ownKeys = Object.keys(source);
80
- if (typeof Object.getOwnPropertySymbols === "function") {
81
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
82
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
83
- }));
84
- }
85
- ownKeys.forEach(function(key) {
86
- _define_property(target, key, source[key]);
87
- });
88
- }
89
- return target;
90
- }
91
- function _sliced_to_array(arr, i) {
92
- return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
93
- }
94
- function _unsupported_iterable_to_array(o, minLen) {
95
- if (!o) return;
96
- if (typeof o === "string") return _array_like_to_array(o, minLen);
97
- var n = Object.prototype.toString.call(o).slice(8, -1);
98
- if (n === "Object" && o.constructor) n = o.constructor.name;
99
- if (n === "Map" || n === "Set") return Array.from(n);
100
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
101
- }
102
- var usePrefetch = function(options) {
103
- var isFirstMounted = useFirstMounted();
104
- if (isFirstMounted) {
105
- var startTiming = performance.now();
106
- index.logger.info("2. Start Get Prefetch Data: ".concat(options.id, " - ").concat(options.functionId || 'default', " - ").concat(startTiming));
107
- }
108
- var id = options.id, functionId = options.functionId, deferId = options.deferId;
109
- var prefetchInfo = {
110
- id: id,
111
- functionId: functionId
112
- };
113
- var mfScope = runtimeUtils.getScope();
114
- var state;
115
- var prefetchResult = universal.prefetch(options);
116
- if (deferId) {
117
- if (_instanceof(prefetchResult, Promise)) {
118
- state = prefetchResult.then(function(deferredData) {
119
- return deferredData.data[deferId];
120
- });
121
- } else {
122
- state = prefetchResult.data[deferId];
123
- }
124
- } else {
125
- state = prefetchResult;
126
- }
127
- var _useState = _sliced_to_array(react.useState(state), 2), prefetchState = _useState[0], setPrefetchState = _useState[1];
128
- var prefetchInstance = prefetch.MFDataPrefetch.getInstance(mfScope);
129
- react.useEffect(function() {
130
- var useEffectTiming = performance.now();
131
- index.logger.info("3. Start Execute UseEffect: ".concat(options.id, " - ").concat(options.functionId || 'default', " - ").concat(useEffectTiming));
132
- return function() {
133
- prefetchInstance === null || prefetchInstance === void 0 ? void 0 : prefetchInstance.markOutdate(prefetchInfo, true);
134
- };
135
- }, []);
136
- var refreshExecutor = function(refetchParams) {
137
- var refetchOptions = _object_spread({}, options);
138
- if (refetchParams) {
139
- refetchOptions.refetchParams = refetchParams;
140
- }
141
- prefetchInstance === null || prefetchInstance === void 0 ? void 0 : prefetchInstance.markOutdate(prefetchInfo, true);
142
- var newVal = universal.prefetch(refetchOptions);
143
- var newState;
144
- if (deferId) {
145
- if (_instanceof(newVal, Promise)) {
146
- newState = newVal.then(function(deferredData) {
147
- return deferredData.data[deferId];
148
- });
149
- } else {
150
- newState = newVal.data[deferId];
151
- }
152
- } else {
153
- newState = newVal;
154
- }
155
- setPrefetchState(newState);
156
- };
157
- return [
158
- prefetchState,
159
- refreshExecutor
160
- ];
161
- };
162
-
163
- exports.usePrefetch = usePrefetch;
package/dist/react.esm.js DELETED
@@ -1,159 +0,0 @@
1
- import { useRef, useEffect, useState } from 'react';
2
- import { l as logger } from './index.esm2.js';
3
- import { M as MFDataPrefetch } from './prefetch.esm.js';
4
- import { prefetch } from './universal.esm.js';
5
- import { b as getScope } from './runtime-utils.esm.js';
6
- import '@module-federation/sdk';
7
- import '@module-federation/runtime';
8
-
9
- var useFirstMounted = function() {
10
- var ref = useRef(true);
11
- useEffect(function() {
12
- ref.current = false;
13
- }, []);
14
- return ref.current;
15
- };
16
-
17
- function _array_like_to_array(arr, len) {
18
- if (len == null || len > arr.length) len = arr.length;
19
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
20
- return arr2;
21
- }
22
- function _array_with_holes(arr) {
23
- if (Array.isArray(arr)) return arr;
24
- }
25
- function _define_property(obj, key, value) {
26
- if (key in obj) {
27
- Object.defineProperty(obj, key, {
28
- value: value,
29
- enumerable: true,
30
- configurable: true,
31
- writable: true
32
- });
33
- } else {
34
- obj[key] = value;
35
- }
36
- return obj;
37
- }
38
- function _instanceof(left, right) {
39
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
40
- return !!right[Symbol.hasInstance](left);
41
- } else {
42
- return left instanceof right;
43
- }
44
- }
45
- function _iterable_to_array_limit(arr, i) {
46
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
47
- if (_i == null) return;
48
- var _arr = [];
49
- var _n = true;
50
- var _d = false;
51
- var _s, _e;
52
- try {
53
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
54
- _arr.push(_s.value);
55
- if (i && _arr.length === i) break;
56
- }
57
- } catch (err) {
58
- _d = true;
59
- _e = err;
60
- } finally{
61
- try {
62
- if (!_n && _i["return"] != null) _i["return"]();
63
- } finally{
64
- if (_d) throw _e;
65
- }
66
- }
67
- return _arr;
68
- }
69
- function _non_iterable_rest() {
70
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
71
- }
72
- function _object_spread(target) {
73
- for(var i = 1; i < arguments.length; i++){
74
- var source = arguments[i] != null ? arguments[i] : {};
75
- var ownKeys = Object.keys(source);
76
- if (typeof Object.getOwnPropertySymbols === "function") {
77
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
78
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
79
- }));
80
- }
81
- ownKeys.forEach(function(key) {
82
- _define_property(target, key, source[key]);
83
- });
84
- }
85
- return target;
86
- }
87
- function _sliced_to_array(arr, i) {
88
- return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
89
- }
90
- function _unsupported_iterable_to_array(o, minLen) {
91
- if (!o) return;
92
- if (typeof o === "string") return _array_like_to_array(o, minLen);
93
- var n = Object.prototype.toString.call(o).slice(8, -1);
94
- if (n === "Object" && o.constructor) n = o.constructor.name;
95
- if (n === "Map" || n === "Set") return Array.from(n);
96
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
97
- }
98
- var usePrefetch = function(options) {
99
- var isFirstMounted = useFirstMounted();
100
- if (isFirstMounted) {
101
- var startTiming = performance.now();
102
- logger.info("2. Start Get Prefetch Data: ".concat(options.id, " - ").concat(options.functionId || 'default', " - ").concat(startTiming));
103
- }
104
- var id = options.id, functionId = options.functionId, deferId = options.deferId;
105
- var prefetchInfo = {
106
- id: id,
107
- functionId: functionId
108
- };
109
- var mfScope = getScope();
110
- var state;
111
- var prefetchResult = prefetch(options);
112
- if (deferId) {
113
- if (_instanceof(prefetchResult, Promise)) {
114
- state = prefetchResult.then(function(deferredData) {
115
- return deferredData.data[deferId];
116
- });
117
- } else {
118
- state = prefetchResult.data[deferId];
119
- }
120
- } else {
121
- state = prefetchResult;
122
- }
123
- var _useState = _sliced_to_array(useState(state), 2), prefetchState = _useState[0], setPrefetchState = _useState[1];
124
- var prefetchInstance = MFDataPrefetch.getInstance(mfScope);
125
- useEffect(function() {
126
- var useEffectTiming = performance.now();
127
- logger.info("3. Start Execute UseEffect: ".concat(options.id, " - ").concat(options.functionId || 'default', " - ").concat(useEffectTiming));
128
- return function() {
129
- prefetchInstance === null || prefetchInstance === void 0 ? void 0 : prefetchInstance.markOutdate(prefetchInfo, true);
130
- };
131
- }, []);
132
- var refreshExecutor = function(refetchParams) {
133
- var refetchOptions = _object_spread({}, options);
134
- if (refetchParams) {
135
- refetchOptions.refetchParams = refetchParams;
136
- }
137
- prefetchInstance === null || prefetchInstance === void 0 ? void 0 : prefetchInstance.markOutdate(prefetchInfo, true);
138
- var newVal = prefetch(refetchOptions);
139
- var newState;
140
- if (deferId) {
141
- if (_instanceof(newVal, Promise)) {
142
- newState = newVal.then(function(deferredData) {
143
- return deferredData.data[deferId];
144
- });
145
- } else {
146
- newState = newVal.data[deferId];
147
- }
148
- } else {
149
- newState = newVal;
150
- }
151
- setPrefetchState(newState);
152
- };
153
- return [
154
- prefetchState,
155
- refreshExecutor
156
- ];
157
- };
158
-
159
- export { usePrefetch };
@@ -1,31 +0,0 @@
1
- 'use strict';
2
-
3
- var runtime = require('@module-federation/runtime');
4
- var sdk = require('@module-federation/sdk');
5
-
6
- var getScope = function() {
7
- return runtime.getInstance().options.name;
8
- };
9
- var getPrefetchId = function(id) {
10
- return sdk.encodeName("".concat(id, "/").concat(sdk.MFPrefetchCommon.identifier));
11
- };
12
- var compatGetPrefetchId = function(id) {
13
- return sdk.encodeName("".concat(id, "/VmokPrefetch"));
14
- };
15
- var getSignalFromManifest = function(remoteSnapshot) {
16
- if (!remoteSnapshot) {
17
- return false;
18
- }
19
- if (!('prefetchEntry' in remoteSnapshot) && !('prefetchInterface' in remoteSnapshot)) {
20
- return false;
21
- }
22
- if (!remoteSnapshot.prefetchEntry && !remoteSnapshot.prefetchInterface) {
23
- return false;
24
- }
25
- return true;
26
- };
27
-
28
- exports.compatGetPrefetchId = compatGetPrefetchId;
29
- exports.getPrefetchId = getPrefetchId;
30
- exports.getScope = getScope;
31
- exports.getSignalFromManifest = getSignalFromManifest;
@@ -1,26 +0,0 @@
1
- import { getInstance } from '@module-federation/runtime';
2
- import { encodeName, MFPrefetchCommon } from '@module-federation/sdk';
3
-
4
- var getScope = function() {
5
- return getInstance().options.name;
6
- };
7
- var getPrefetchId = function(id) {
8
- return encodeName("".concat(id, "/").concat(MFPrefetchCommon.identifier));
9
- };
10
- var compatGetPrefetchId = function(id) {
11
- return encodeName("".concat(id, "/VmokPrefetch"));
12
- };
13
- var getSignalFromManifest = function(remoteSnapshot) {
14
- if (!remoteSnapshot) {
15
- return false;
16
- }
17
- if (!('prefetchEntry' in remoteSnapshot) && !('prefetchInterface' in remoteSnapshot)) {
18
- return false;
19
- }
20
- if (!remoteSnapshot.prefetchEntry && !remoteSnapshot.prefetchInterface) {
21
- return false;
22
- }
23
- return true;
24
- };
25
-
26
- export { getSignalFromManifest as a, getScope as b, compatGetPrefetchId as c, getPrefetchId as g };
@@ -1,2 +0,0 @@
1
- export * from "./src/shared/index";
2
- export { default } from "./src/shared/index";
@@ -1,26 +0,0 @@
1
- 'use strict';
2
-
3
- var sharedStrategy = function() {
4
- return {
5
- name: 'shared-strategy',
6
- beforeInit: function beforeInit(args) {
7
- var userOptions = args.userOptions;
8
- var shared = userOptions.shared;
9
- if (shared) {
10
- Object.keys(shared).forEach(function(sharedKey) {
11
- var sharedConfigs = shared[sharedKey];
12
- var arraySharedConfigs = Array.isArray(sharedConfigs) ? sharedConfigs : [
13
- sharedConfigs
14
- ];
15
- arraySharedConfigs.forEach(function(s) {
16
- s.strategy = 'loaded-first';
17
- });
18
- });
19
- console.warn("[Module Federation Data Prefetch]: Your shared strategy is set to 'loaded-first', this is a necessary condition for data prefetch");
20
- }
21
- return args;
22
- }
23
- };
24
- };
25
-
26
- module.exports = sharedStrategy;
@@ -1,24 +0,0 @@
1
- var sharedStrategy = function() {
2
- return {
3
- name: 'shared-strategy',
4
- beforeInit: function beforeInit(args) {
5
- var userOptions = args.userOptions;
6
- var shared = userOptions.shared;
7
- if (shared) {
8
- Object.keys(shared).forEach(function(sharedKey) {
9
- var sharedConfigs = shared[sharedKey];
10
- var arraySharedConfigs = Array.isArray(sharedConfigs) ? sharedConfigs : [
11
- sharedConfigs
12
- ];
13
- arraySharedConfigs.forEach(function(s) {
14
- s.strategy = 'loaded-first';
15
- });
16
- });
17
- console.warn("[Module Federation Data Prefetch]: Your shared strategy is set to 'loaded-first', this is a necessary condition for data prefetch");
18
- }
19
- return args;
20
- }
21
- };
22
- };
23
-
24
- export { sharedStrategy as default };
@@ -1 +0,0 @@
1
- export declare const TEMP_DIR = ".mf";
@@ -1 +0,0 @@
1
- export * from './constant';
@@ -1,2 +0,0 @@
1
- export declare const fileExistsWithCaseSync: (filepath: string) => boolean;
2
- export declare const fixPrefetchPath: (exposePath: string) => Array<string>;
@@ -1,5 +0,0 @@
1
- import { ModuleInfo } from '@module-federation/sdk';
2
- export declare const getScope: () => string;
3
- export declare const getPrefetchId: (id: string) => string;
4
- export declare const compatGetPrefetchId: (id: string) => string;
5
- export declare const getSignalFromManifest: (remoteSnapshot: ModuleInfo) => boolean;
@@ -1,2 +0,0 @@
1
- export * from './prefetch';
2
- export * from './plugin';
@@ -1,3 +0,0 @@
1
- import { Logger } from '@module-federation/sdk';
2
- declare const _default: Logger;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import type { FederationRuntimePlugin } from '@module-federation/runtime/types';
2
- export declare const prefetchPlugin: () => FederationRuntimePlugin;
3
- export default prefetchPlugin;
@@ -1,11 +0,0 @@
1
- import { type prefetchOptions } from '../prefetch';
2
- type refetchParams = any;
3
- type prefetchReturnType<T> = [
4
- Promise<T>,
5
- (refetchParams?: refetchParams) => void
6
- ];
7
- type UsePrefetchOptions = prefetchOptions & {
8
- deferId?: string;
9
- };
10
- export declare const usePrefetch: <T>(options: UsePrefetchOptions) => prefetchReturnType<T>;
11
- export {};
@@ -1 +0,0 @@
1
- export * from './hooks';
@@ -1 +0,0 @@
1
- export declare const useFirstMounted: () => boolean;
@@ -1,3 +0,0 @@
1
- import type { FederationRuntimePlugin } from '@module-federation/runtime';
2
- declare const sharedStrategy: () => FederationRuntimePlugin;
3
- export default sharedStrategy;
@@ -1,2 +0,0 @@
1
- import { type prefetchOptions } from '../prefetch';
2
- export declare function prefetch(options: prefetchOptions): Promise<any>;
@@ -1 +0,0 @@
1
- export * from "./src/universal/index";
@@ -1,38 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var prefetch$1 = require('./prefetch.cjs.js');
6
- var runtimeUtils = require('./runtime-utils.cjs.js');
7
- require('@module-federation/runtime');
8
- require('@module-federation/sdk');
9
-
10
- function _instanceof(left, right) {
11
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
12
- return !!right[Symbol.hasInstance](left);
13
- } else {
14
- return left instanceof right;
15
- }
16
- }
17
- function prefetch(options) {
18
- var id = options.id, _options_functionId = options.functionId, functionId = _options_functionId === void 0 ? 'default' : _options_functionId;
19
- var mfScope = runtimeUtils.getScope();
20
- var prefetchInstance = prefetch$1.MFDataPrefetch.getInstance(mfScope) || new prefetch$1.MFDataPrefetch({
21
- name: mfScope
22
- });
23
- var res = prefetchInstance.getProjectExports();
24
- if (_instanceof(res, Promise)) {
25
- var promise = res.then(function() {
26
- var result = prefetchInstance.prefetch(options);
27
- prefetchInstance.memorize(id + functionId, result);
28
- return result;
29
- });
30
- return promise;
31
- } else {
32
- var result = prefetchInstance.prefetch(options);
33
- prefetchInstance.memorize(id + functionId, result);
34
- return result;
35
- }
36
- }
37
-
38
- exports.prefetch = prefetch;
@@ -1,34 +0,0 @@
1
- import { M as MFDataPrefetch } from './prefetch.esm.js';
2
- import { b as getScope } from './runtime-utils.esm.js';
3
- import '@module-federation/runtime';
4
- import '@module-federation/sdk';
5
-
6
- function _instanceof(left, right) {
7
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
8
- return !!right[Symbol.hasInstance](left);
9
- } else {
10
- return left instanceof right;
11
- }
12
- }
13
- function prefetch(options) {
14
- var id = options.id, _options_functionId = options.functionId, functionId = _options_functionId === void 0 ? 'default' : _options_functionId;
15
- var mfScope = getScope();
16
- var prefetchInstance = MFDataPrefetch.getInstance(mfScope) || new MFDataPrefetch({
17
- name: mfScope
18
- });
19
- var res = prefetchInstance.getProjectExports();
20
- if (_instanceof(res, Promise)) {
21
- var promise = res.then(function() {
22
- var result = prefetchInstance.prefetch(options);
23
- prefetchInstance.memorize(id + functionId, result);
24
- return result;
25
- });
26
- return promise;
27
- } else {
28
- var result = prefetchInstance.prefetch(options);
29
- prefetchInstance.memorize(id + functionId, result);
30
- return result;
31
- }
32
- }
33
-
34
- export { prefetch };
package/rollup.config.js DELETED
@@ -1,25 +0,0 @@
1
- const copy = require('rollup-plugin-copy');
2
-
3
- module.exports = (rollupConfig, _projectOptions) => {
4
- rollupConfig.plugins.push(
5
- copy({
6
- targets: [
7
- {
8
- src: 'packages/data-prefetch/LICENSE',
9
- dest: 'packages/data-prefetch/dist',
10
- },
11
- ],
12
- }),
13
- );
14
- rollupConfig.input = {
15
- index: 'packages/data-prefetch/src/index.ts',
16
- react: 'packages/data-prefetch/src/react/index.ts',
17
- cli: 'packages/data-prefetch/src/cli/index.ts',
18
- babel: 'packages/data-prefetch/src/cli/babel.ts',
19
- universal: 'packages/data-prefetch/src/universal/index.ts',
20
- plugin: 'packages/data-prefetch/src/plugin.ts',
21
- shared: 'packages/data-prefetch/src/shared/index.ts',
22
- };
23
- rollupConfig.external = [/@module-federation/];
24
- return rollupConfig;
25
- };
package/tsconfig.lib.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "../../dist/out-tsc",
5
- "declaration": true,
6
- "types": ["node"]
7
- },
8
- "include": ["src/**/*.ts"],
9
- "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
10
- }