@module-federation/data-prefetch 0.0.0-next-20240924012324 → 0.0.0-next-20240924091419
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 +4 -13
- package/dist/cli/index.js +8 -10
- package/dist/esm/{chunk-L7EVPWJ4.js → chunk-ISLXMAIA.js} +2 -2
- package/dist/esm/{chunk-FKXFJ2Y4.js → chunk-KI4QGPIS.js} +1 -1
- package/dist/esm/{chunk-EK6Q2YBB.js → chunk-VVZ6XIM6.js} +1 -1
- package/dist/esm/cli/index.js +8 -10
- 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-c08be471.d.ts → prefetch-4e9646e4.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 +8 -10
- package/src/prefetch.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
# @module-federation/data-prefetch
|
|
2
2
|
|
|
3
|
-
## 0.0.0-next-
|
|
3
|
+
## 0.0.0-next-20240924091419
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
-
|
|
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-20240924012324
|
|
18
|
-
- @module-federation/sdk@0.0.0-next-20240924012324
|
|
7
|
+
- Updated dependencies [3082116]
|
|
8
|
+
- @module-federation/runtime@0.0.0-next-20240924091419
|
|
9
|
+
- @module-federation/sdk@0.0.0-next-20240924091419
|
|
19
10
|
|
|
20
11
|
## 0.6.6
|
|
21
12
|
|
package/dist/cli/index.js
CHANGED
|
@@ -167,16 +167,14 @@ 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
|
-
|
|
178
|
-
`globalThis.__FEDERATION__['${import_sdk2.MFPrefetchCommon.globalKey}']['${import_sdk2.MFPrefetchCommon.exportsKey}']['${options.name}'] = function(){ return import('${prefetchEntry}');}`
|
|
179
|
-
]),
|
|
170
|
+
`globalThis.__FEDERATION__ = globalThis.__FEDERATION__ || {};`,
|
|
171
|
+
`globalThis.__FEDERATION__['${import_sdk2.MFPrefetchCommon.globalKey}'] = globalThis.__FEDERATION__['${import_sdk2.MFPrefetchCommon.globalKey}'] || {`,
|
|
172
|
+
`entryLoading: {},`,
|
|
173
|
+
`instance: new Map(),`,
|
|
174
|
+
`__PREFETCH_EXPORTS__: {},`,
|
|
175
|
+
`};`,
|
|
176
|
+
`globalThis.__FEDERATION__['${import_sdk2.MFPrefetchCommon.globalKey}']['${import_sdk2.MFPrefetchCommon.exportsKey}'] = globalThis.__FEDERATION__['${import_sdk2.MFPrefetchCommon.globalKey}']['${import_sdk2.MFPrefetchCommon.exportsKey}'] || {};`,
|
|
177
|
+
`globalThis.__FEDERATION__['${import_sdk2.MFPrefetchCommon.globalKey}']['${import_sdk2.MFPrefetchCommon.exportsKey}']['${options.name}'] = import('${prefetchEntry}');`,
|
|
180
178
|
"}",
|
|
181
179
|
`${federationGlobal}.prefetch = injectPrefetch`
|
|
182
180
|
]) : "",
|
|
@@ -52,12 +52,12 @@ var MFDataPrefetch = class {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
getProjectExports() {
|
|
55
|
-
var _a2
|
|
55
|
+
var _a2;
|
|
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 = (
|
|
60
|
+
const exportsPromise = (_a2 = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) == null ? void 0 : _a2[name];
|
|
61
61
|
const resolve = exportsPromise.then(
|
|
62
62
|
(exports = {}) => {
|
|
63
63
|
const memory = {};
|
package/dist/esm/cli/index.js
CHANGED
|
@@ -141,16 +141,14 @@ 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
|
-
|
|
152
|
-
`globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}']['${options.name}'] = function(){ return import('${prefetchEntry}');}`
|
|
153
|
-
]),
|
|
144
|
+
`globalThis.__FEDERATION__ = globalThis.__FEDERATION__ || {};`,
|
|
145
|
+
`globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}'] = globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}'] || {`,
|
|
146
|
+
`entryLoading: {},`,
|
|
147
|
+
`instance: new Map(),`,
|
|
148
|
+
`__PREFETCH_EXPORTS__: {},`,
|
|
149
|
+
`};`,
|
|
150
|
+
`globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}'] = globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}'] || {};`,
|
|
151
|
+
`globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}']['${options.name}'] = import('${prefetchEntry}');`,
|
|
154
152
|
"}",
|
|
155
153
|
`${federationGlobal}.prefetch = injectPrefetch`
|
|
156
154
|
]) : "",
|
package/dist/esm/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
prefetchPlugin
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VVZ6XIM6.js";
|
|
4
4
|
import "./chunk-TTJJJ2WZ.js";
|
|
5
5
|
import {
|
|
6
6
|
MFDataPrefetch
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ISLXMAIA.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-VVZ6XIM6.js";
|
|
5
5
|
import "./chunk-TTJJJ2WZ.js";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-ISLXMAIA.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-KI4QGPIS.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-ISLXMAIA.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-4e9646e4.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;
|
|
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 = (
|
|
97
|
+
const exportsPromise = (_a2 = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) == null ? void 0 : _a2[name];
|
|
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;
|
|
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 = (
|
|
96
|
+
const exportsPromise = (_a2 = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) == null ? void 0 : _a2[name];
|
|
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,
|
|
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;
|
|
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 = (
|
|
94
|
+
const exportsPromise = (_a2 = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) == null ? void 0 : _a2[name];
|
|
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;
|
|
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 = (
|
|
87
|
+
const exportsPromise = (_a2 = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) == null ? void 0 : _a2[name];
|
|
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-20240924091419",
|
|
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-20240924091419",
|
|
89
|
+
"@module-federation/runtime": "0.0.0-next-20240924091419"
|
|
90
90
|
},
|
|
91
91
|
"scripts": {
|
|
92
92
|
"dev": "cross-env WATCH=true tsup",
|
package/src/cli/index.ts
CHANGED
|
@@ -135,16 +135,14 @@ 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
|
-
|
|
146
|
-
`globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}']['${options.name}'] = function(){ return import('${prefetchEntry}');}`,
|
|
147
|
-
]),
|
|
138
|
+
`globalThis.__FEDERATION__ = globalThis.__FEDERATION__ || {};`,
|
|
139
|
+
`globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}'] = globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}'] || {`,
|
|
140
|
+
`entryLoading: {},`,
|
|
141
|
+
`instance: new Map(),`,
|
|
142
|
+
`__PREFETCH_EXPORTS__: {},`,
|
|
143
|
+
`};`,
|
|
144
|
+
`globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}'] = globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}'] || {};`,
|
|
145
|
+
`globalThis.__FEDERATION__['${MFPrefetchCommon.globalKey}']['${MFPrefetchCommon.exportsKey}']['${options.name}'] = import('${prefetchEntry}');`,
|
|
148
146
|
'}',
|
|
149
147
|
`${federationGlobal}.prefetch = injectPrefetch`,
|
|
150
148
|
])
|
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,
|
|
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.
|