@module-federation/data-prefetch 0.0.0-next-20240923073245 → 0.0.0-next-20240924022552
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/CHANGELOG.md +13 -4
- package/dist/cli/index.js +10 -8
- package/dist/esm/{chunk-VVZ6XIM6.js → chunk-EK6Q2YBB.js} +1 -1
- package/dist/esm/{chunk-KI4QGPIS.js → chunk-FKXFJ2Y4.js} +1 -1
- package/dist/esm/{chunk-ISLXMAIA.js → chunk-L7EVPWJ4.js} +2 -2
- package/dist/esm/cli/index.js +10 -8
- package/dist/esm/index.js +2 -2
- package/dist/esm/plugin.js +2 -2
- package/dist/esm/react/index.js +2 -2
- package/dist/esm/universal/index.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/plugin.js +2 -2
- package/dist/{prefetch-4e9646e4.d.ts → prefetch-c08be471.d.ts} +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +2 -2
- package/dist/universal/index.d.ts +1 -1
- package/dist/universal/index.js +2 -2
- package/jest.config.js +1 -1
- package/package.json +3 -3
- package/src/cli/index.ts +10 -8
- package/src/prefetch.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
# @module-federation/data-prefetch
|
|
2
2
|
|
|
3
|
-
## 0.0.0-next-
|
|
3
|
+
## 0.0.0-next-20240924022552
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
-
|
|
7
|
+
- f10cf55: Refactored the way prefetch entries are imported for improved dynamic loading handling.
|
|
8
|
+
|
|
9
|
+
- Changed the import of prefetch entries to use a function wrapper for more dynamic control.
|
|
10
|
+
- Updated data types to ensure consistency with the new function-based import approach.
|
|
11
|
+
- Modified the `injectPrefetch` function structure to incorporate the new import method.
|
|
12
|
+
- Modified the `MFDataPrefetch` class to handle the new import function when resolving exports.
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [3837c89]
|
|
15
|
+
- Updated dependencies [3837c89]
|
|
16
|
+
- Updated dependencies [59e0069]
|
|
17
|
+
- @module-federation/runtime@0.0.0-next-20240924022552
|
|
18
|
+
- @module-federation/sdk@0.0.0-next-20240924022552
|
|
10
19
|
|
|
11
20
|
## 0.6.6
|
|
12
21
|
|
package/dist/cli/index.js
CHANGED
|
@@ -167,14 +167,16 @@ var PrefetchPlugin = class {
|
|
|
167
167
|
return Template.asString([
|
|
168
168
|
import_fs_extra2.default.existsSync(prefetchEntry) ? Template.indent([
|
|
169
169
|
"function injectPrefetch() {",
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
170
|
+
Template.indent([
|
|
171
|
+
`globalThis.__FEDERATION__ = globalThis.__FEDERATION__ || {};`,
|
|
172
|
+
`globalThis.__FEDERATION__['${import_sdk2.MFPrefetchCommon.globalKey}'] = globalThis.__FEDERATION__['${import_sdk2.MFPrefetchCommon.globalKey}'] || {`,
|
|
173
|
+
`entryLoading: {},`,
|
|
174
|
+
`instance: new Map(),`,
|
|
175
|
+
`__PREFETCH_EXPORTS__: {},`,
|
|
176
|
+
`};`,
|
|
177
|
+
`globalThis.__FEDERATION__['${import_sdk2.MFPrefetchCommon.globalKey}']['${import_sdk2.MFPrefetchCommon.exportsKey}'] = globalThis.__FEDERATION__['${import_sdk2.MFPrefetchCommon.globalKey}']['${import_sdk2.MFPrefetchCommon.exportsKey}'] || {};`,
|
|
178
|
+
`globalThis.__FEDERATION__['${import_sdk2.MFPrefetchCommon.globalKey}']['${import_sdk2.MFPrefetchCommon.exportsKey}']['${options.name}'] = function(){ return import('${prefetchEntry}');}`
|
|
179
|
+
]),
|
|
178
180
|
"}",
|
|
179
181
|
`${federationGlobal}.prefetch = injectPrefetch`
|
|
180
182
|
]) : "",
|
|
@@ -52,12 +52,12 @@ var MFDataPrefetch = class {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
getProjectExports() {
|
|
55
|
-
var _a2;
|
|
55
|
+
var _a2, _b;
|
|
56
56
|
if (Object.keys(this._exports).length > 0) {
|
|
57
57
|
return this._exports;
|
|
58
58
|
}
|
|
59
59
|
const { name } = this._options;
|
|
60
|
-
const exportsPromise = (_a2 = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) == null ? void 0 : _a2[name];
|
|
60
|
+
const exportsPromise = (_b = (_a2 = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) == null ? void 0 : _a2[name]) == null ? void 0 : _b.call(_a2);
|
|
61
61
|
const resolve = exportsPromise.then(
|
|
62
62
|
(exports = {}) => {
|
|
63
63
|
const memory = {};
|
package/dist/esm/cli/index.js
CHANGED
|
@@ -141,14 +141,16 @@ var PrefetchPlugin = class {
|
|
|
141
141
|
return Template.asString([
|
|
142
142
|
fs2.existsSync(prefetchEntry) ? Template.indent([
|
|
143
143
|
"function injectPrefetch() {",
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
144
|
+
Template.indent([
|
|
145
|
+
`globalThis.__FEDERATION__ = globalThis.__FEDERATION__ || {};`,
|
|
146
|
+
`globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}'] = globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}'] || {`,
|
|
147
|
+
`entryLoading: {},`,
|
|
148
|
+
`instance: new Map(),`,
|
|
149
|
+
`__PREFETCH_EXPORTS__: {},`,
|
|
150
|
+
`};`,
|
|
151
|
+
`globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}'] = globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}'] || {};`,
|
|
152
|
+
`globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}']['${options.name}'] = function(){ return import('${prefetchEntry}');}`
|
|
153
|
+
]),
|
|
152
154
|
"}",
|
|
153
155
|
`${federationGlobal}.prefetch = injectPrefetch`
|
|
154
156
|
]) : "",
|
package/dist/esm/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
prefetchPlugin
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-EK6Q2YBB.js";
|
|
4
4
|
import "./chunk-TTJJJ2WZ.js";
|
|
5
5
|
import {
|
|
6
6
|
MFDataPrefetch
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-L7EVPWJ4.js";
|
|
8
8
|
import "./chunk-AJPO2B2T.js";
|
|
9
9
|
import "./chunk-EZUCZHGV.js";
|
|
10
10
|
export {
|
package/dist/esm/plugin.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
plugin_default,
|
|
3
3
|
prefetchPlugin
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-EK6Q2YBB.js";
|
|
5
5
|
import "./chunk-TTJJJ2WZ.js";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-L7EVPWJ4.js";
|
|
7
7
|
import "./chunk-AJPO2B2T.js";
|
|
8
8
|
import "./chunk-EZUCZHGV.js";
|
|
9
9
|
export {
|
package/dist/esm/react/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
prefetch
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-FKXFJ2Y4.js";
|
|
4
4
|
import {
|
|
5
5
|
logger_default
|
|
6
6
|
} from "../chunk-TTJJJ2WZ.js";
|
|
7
7
|
import {
|
|
8
8
|
MFDataPrefetch
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-L7EVPWJ4.js";
|
|
10
10
|
import {
|
|
11
11
|
getScope
|
|
12
12
|
} from "../chunk-AJPO2B2T.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { D as DataPrefetchOptions, M as MFDataPrefetch, p as prefetchOptions } from './prefetch-
|
|
1
|
+
export { D as DataPrefetchOptions, M as MFDataPrefetch, p as prefetchOptions } from './prefetch-c08be471.js';
|
|
2
2
|
export { default as prefetchPlugin } from './plugin.js';
|
|
3
3
|
import '@module-federation/runtime';
|
|
4
4
|
import '@module-federation/sdk';
|
package/dist/index.js
CHANGED
|
@@ -89,12 +89,12 @@ var MFDataPrefetch = class {
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
getProjectExports() {
|
|
92
|
-
var _a2;
|
|
92
|
+
var _a2, _b;
|
|
93
93
|
if (Object.keys(this._exports).length > 0) {
|
|
94
94
|
return this._exports;
|
|
95
95
|
}
|
|
96
96
|
const { name } = this._options;
|
|
97
|
-
const exportsPromise = (_a2 = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) == null ? void 0 : _a2[name];
|
|
97
|
+
const exportsPromise = (_b = (_a2 = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) == null ? void 0 : _a2[name]) == null ? void 0 : _b.call(_a2);
|
|
98
98
|
const resolve = exportsPromise.then(
|
|
99
99
|
(exports = {}) => {
|
|
100
100
|
const memory = {};
|
package/dist/plugin.js
CHANGED
|
@@ -88,12 +88,12 @@ var MFDataPrefetch = class {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
getProjectExports() {
|
|
91
|
-
var _a2;
|
|
91
|
+
var _a2, _b;
|
|
92
92
|
if (Object.keys(this._exports).length > 0) {
|
|
93
93
|
return this._exports;
|
|
94
94
|
}
|
|
95
95
|
const { name } = this._options;
|
|
96
|
-
const exportsPromise = (_a2 = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) == null ? void 0 : _a2[name];
|
|
96
|
+
const exportsPromise = (_b = (_a2 = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) == null ? void 0 : _a2[name]) == null ? void 0 : _b.call(_a2);
|
|
97
97
|
const resolve = exportsPromise.then(
|
|
98
98
|
(exports = {}) => {
|
|
99
99
|
const memory = {};
|
|
@@ -7,7 +7,7 @@ declare module '@module-federation/runtime' {
|
|
|
7
7
|
__PREFETCH__: {
|
|
8
8
|
entryLoading: Record<string, undefined | Promise<void>>;
|
|
9
9
|
instance: Map<string, MFDataPrefetch>;
|
|
10
|
-
__PREFETCH_EXPORTS__: Record<string, Promise<Record<string, any>>>;
|
|
10
|
+
__PREFETCH_EXPORTS__: Record<string, () => Promise<Record<string, any>>>;
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
}
|
package/dist/react/index.d.ts
CHANGED
package/dist/react/index.js
CHANGED
|
@@ -86,12 +86,12 @@ var MFDataPrefetch = class {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
getProjectExports() {
|
|
89
|
-
var _a2;
|
|
89
|
+
var _a2, _b;
|
|
90
90
|
if (Object.keys(this._exports).length > 0) {
|
|
91
91
|
return this._exports;
|
|
92
92
|
}
|
|
93
93
|
const { name } = this._options;
|
|
94
|
-
const exportsPromise = (_a2 = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) == null ? void 0 : _a2[name];
|
|
94
|
+
const exportsPromise = (_b = (_a2 = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) == null ? void 0 : _a2[name]) == null ? void 0 : _b.call(_a2);
|
|
95
95
|
const resolve = exportsPromise.then(
|
|
96
96
|
(exports = {}) => {
|
|
97
97
|
const memory = {};
|
package/dist/universal/index.js
CHANGED
|
@@ -79,12 +79,12 @@ var MFDataPrefetch = class {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
getProjectExports() {
|
|
82
|
-
var _a2;
|
|
82
|
+
var _a2, _b;
|
|
83
83
|
if (Object.keys(this._exports).length > 0) {
|
|
84
84
|
return this._exports;
|
|
85
85
|
}
|
|
86
86
|
const { name } = this._options;
|
|
87
|
-
const exportsPromise = (_a2 = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) == null ? void 0 : _a2[name];
|
|
87
|
+
const exportsPromise = (_b = (_a2 = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) == null ? void 0 : _a2[name]) == null ? void 0 : _b.call(_a2);
|
|
88
88
|
const resolve = exportsPromise.then(
|
|
89
89
|
(exports = {}) => {
|
|
90
90
|
const memory = {};
|
package/jest.config.js
CHANGED
|
@@ -24,6 +24,6 @@ module.exports = {
|
|
|
24
24
|
'^.+\\.(t|j)sx?$': ['@swc/jest', { swcrc: false }],
|
|
25
25
|
},
|
|
26
26
|
rootDir: __dirname,
|
|
27
|
-
testMatch: ['<rootDir
|
|
27
|
+
testMatch: ['<rootDir>/__tests__/**/*.spec.[jt]s?(x)'],
|
|
28
28
|
testPathIgnorePatterns: ['/node_modules/'],
|
|
29
29
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/data-prefetch",
|
|
3
3
|
"description": "Module Federation Data Prefetch",
|
|
4
|
-
"version": "0.0.0-next-
|
|
4
|
+
"version": "0.0.0-next-20240924022552",
|
|
5
5
|
"author": "nieyan <nyqykk@foxmail.com>",
|
|
6
6
|
"homepage": "https://github.com/module-federation/core",
|
|
7
7
|
"license": "MIT",
|
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
87
|
"fs-extra": "9.1.0",
|
|
88
|
-
"@module-federation/sdk": "0.0.0-next-
|
|
89
|
-
"@module-federation/runtime": "0.0.0-next-
|
|
88
|
+
"@module-federation/sdk": "0.0.0-next-20240924022552",
|
|
89
|
+
"@module-federation/runtime": "0.0.0-next-20240924022552"
|
|
90
90
|
},
|
|
91
91
|
"scripts": {
|
|
92
92
|
"dev": "cross-env WATCH=true tsup",
|
package/src/cli/index.ts
CHANGED
|
@@ -135,14 +135,16 @@ export class PrefetchPlugin implements WebpackPluginInstance {
|
|
|
135
135
|
fs.existsSync(prefetchEntry)
|
|
136
136
|
? Template.indent([
|
|
137
137
|
'function injectPrefetch() {',
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
138
|
+
Template.indent([
|
|
139
|
+
`globalThis.__FEDERATION__ = globalThis.__FEDERATION__ || {};`,
|
|
140
|
+
`globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}'] = globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}'] || {`,
|
|
141
|
+
`entryLoading: {},`,
|
|
142
|
+
`instance: new Map(),`,
|
|
143
|
+
`__PREFETCH_EXPORTS__: {},`,
|
|
144
|
+
`};`,
|
|
145
|
+
`globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}'] = globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}'] || {};`,
|
|
146
|
+
`globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}']['${options.name}'] = function(){ return import('${prefetchEntry}');}`,
|
|
147
|
+
]),
|
|
146
148
|
'}',
|
|
147
149
|
`${federationGlobal}.prefetch = injectPrefetch`,
|
|
148
150
|
])
|
package/src/prefetch.ts
CHANGED
|
@@ -17,7 +17,7 @@ declare module '@module-federation/runtime' {
|
|
|
17
17
|
__PREFETCH__: {
|
|
18
18
|
entryLoading: Record<string, undefined | Promise<void>>;
|
|
19
19
|
instance: Map<string, MFDataPrefetch>;
|
|
20
|
-
__PREFETCH_EXPORTS__: Record<string, Promise<Record<string, any>>>;
|
|
20
|
+
__PREFETCH_EXPORTS__: Record<string, () => Promise<Record<string, any>>>;
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -95,7 +95,7 @@ export class MFDataPrefetch {
|
|
|
95
95
|
}
|
|
96
96
|
const { name } = this._options;
|
|
97
97
|
const exportsPromise =
|
|
98
|
-
globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__?.[name];
|
|
98
|
+
globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__?.[name]?.();
|
|
99
99
|
const resolve = exportsPromise.then(
|
|
100
100
|
(exports: Record<string, Record<string, any>> = {}) => {
|
|
101
101
|
// Match prefetch based on the function name suffix so that other capabilities can be expanded later.
|