@module-federation/data-prefetch 0.0.0-next-20240911083839 → 0.0.0-next-20240918080432
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 +3 -3
- package/dist/cli/index.js +1 -0
- package/dist/esm/{chunk-VWDP6NMM.js → chunk-AJPO2B2T.js} +3 -7
- package/dist/esm/{chunk-57ZXBP7D.js → chunk-ISLXMAIA.js} +1 -1
- package/dist/esm/{chunk-OIIVUMED.js → chunk-KI4QGPIS.js} +4 -4
- package/dist/esm/{chunk-YXTPJG2M.js → chunk-VVZ6XIM6.js} +2 -2
- package/dist/esm/cli/index.js +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/esm/plugin.js +3 -3
- package/dist/esm/react/index.js +4 -4
- package/dist/esm/universal/index.js +3 -3
- package/dist/index.js +4 -3
- package/dist/plugin.js +4 -3
- package/dist/react/index.js +9 -13
- package/dist/universal/index.js +8 -12
- package/package.json +3 -3
- package/src/common/runtime-utils.ts +3 -7
- package/src/react/hooks.ts +1 -1
- package/src/universal/index.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
@module-federation/data-prefetch
|
|
2
2
|
|
|
3
|
-
## 0.0.0-next-
|
|
3
|
+
## 0.0.0-next-20240918080432
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
7
|
- 3ddab21: feat(@module-federation/data-prefetch): support data prefetch in Module Federation
|
|
8
|
-
- @module-federation/runtime@0.0.0-next-
|
|
9
|
-
- @module-federation/sdk@0.0.0-next-
|
|
8
|
+
- @module-federation/runtime@0.0.0-next-20240918080432
|
|
9
|
+
- @module-federation/sdk@0.0.0-next-20240918080432
|
package/dist/cli/index.js
CHANGED
|
@@ -63,6 +63,7 @@ var fixPrefetchPath = (exposePath) => {
|
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
// src/common/runtime-utils.ts
|
|
66
|
+
var import_runtime = require("@module-federation/runtime");
|
|
66
67
|
var import_sdk = require("@module-federation/sdk");
|
|
67
68
|
var getPrefetchId = (id) => (0, import_sdk.encodeName)(`${id}/${import_sdk.MFPrefetchCommon.identifier}`);
|
|
68
69
|
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
// src/common/runtime-utils.ts
|
|
2
|
+
import { getInstance } from "@module-federation/runtime";
|
|
2
3
|
import {
|
|
3
4
|
encodeName,
|
|
4
5
|
MFPrefetchCommon
|
|
5
6
|
} from "@module-federation/sdk";
|
|
6
|
-
var getScope = (
|
|
7
|
-
|
|
8
|
-
if (idArray.length >= 2) {
|
|
9
|
-
idArray.pop();
|
|
10
|
-
}
|
|
11
|
-
const name = idArray.join("/");
|
|
12
|
-
return name;
|
|
7
|
+
var getScope = () => {
|
|
8
|
+
return getInstance().options.name;
|
|
13
9
|
};
|
|
14
10
|
var getPrefetchId = (id) => encodeName(`${id}/${MFPrefetchCommon.identifier}`);
|
|
15
11
|
var compatGetPrefetchId = (id) => encodeName(`${id}/VmokPrefetch`);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MFDataPrefetch
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ISLXMAIA.js";
|
|
4
4
|
import {
|
|
5
5
|
getScope
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-AJPO2B2T.js";
|
|
7
7
|
|
|
8
8
|
// src/universal/index.ts
|
|
9
9
|
function prefetch(options) {
|
|
10
|
-
const { id, functionId } = options;
|
|
11
|
-
const mfScope = getScope(
|
|
10
|
+
const { id, functionId = "default" } = options;
|
|
11
|
+
const mfScope = getScope();
|
|
12
12
|
const prefetchInstance = MFDataPrefetch.getInstance(mfScope) || new MFDataPrefetch({
|
|
13
13
|
name: mfScope
|
|
14
14
|
});
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
} from "./chunk-TTJJJ2WZ.js";
|
|
4
4
|
import {
|
|
5
5
|
MFDataPrefetch
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ISLXMAIA.js";
|
|
7
7
|
import {
|
|
8
8
|
getSignalFromManifest
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-AJPO2B2T.js";
|
|
10
10
|
|
|
11
11
|
// src/plugin.ts
|
|
12
12
|
import { getResourceUrl } from "@module-federation/sdk";
|
package/dist/esm/cli/index.js
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-ISLXMAIA.js";
|
|
8
|
+
import "./chunk-AJPO2B2T.js";
|
|
9
9
|
import "./chunk-EZUCZHGV.js";
|
|
10
10
|
export {
|
|
11
11
|
MFDataPrefetch,
|
package/dist/esm/plugin.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-ISLXMAIA.js";
|
|
7
|
+
import "./chunk-AJPO2B2T.js";
|
|
8
8
|
import "./chunk-EZUCZHGV.js";
|
|
9
9
|
export {
|
|
10
10
|
plugin_default as default,
|
package/dist/esm/react/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
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
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-AJPO2B2T.js";
|
|
13
13
|
import "../chunk-EZUCZHGV.js";
|
|
14
14
|
|
|
15
15
|
// src/react/hooks.ts
|
|
@@ -39,7 +39,7 @@ var usePrefetch = (options) => {
|
|
|
39
39
|
id,
|
|
40
40
|
functionId
|
|
41
41
|
};
|
|
42
|
-
const mfScope = getScope(
|
|
42
|
+
const mfScope = getScope();
|
|
43
43
|
let state;
|
|
44
44
|
const prefetchResult = prefetch(options);
|
|
45
45
|
if (deferId) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
prefetch
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-KI4QGPIS.js";
|
|
4
|
+
import "../chunk-ISLXMAIA.js";
|
|
5
|
+
import "../chunk-AJPO2B2T.js";
|
|
6
6
|
import "../chunk-EZUCZHGV.js";
|
|
7
7
|
export {
|
|
8
8
|
prefetch
|
package/dist/index.js
CHANGED
|
@@ -26,10 +26,11 @@ __export(src_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(src_exports);
|
|
27
27
|
|
|
28
28
|
// src/prefetch.ts
|
|
29
|
-
var
|
|
29
|
+
var import_runtime2 = require("@module-federation/runtime");
|
|
30
30
|
var import_sdk2 = require("@module-federation/sdk");
|
|
31
31
|
|
|
32
32
|
// src/common/runtime-utils.ts
|
|
33
|
+
var import_runtime = require("@module-federation/runtime");
|
|
33
34
|
var import_sdk = require("@module-federation/sdk");
|
|
34
35
|
var getPrefetchId = (id) => (0, import_sdk.encodeName)(`${id}/${import_sdk.MFPrefetchCommon.identifier}`);
|
|
35
36
|
var compatGetPrefetchId = (id) => (0, import_sdk.encodeName)(`${id}/VmokPrefetch`);
|
|
@@ -78,9 +79,9 @@ var MFDataPrefetch = class {
|
|
|
78
79
|
}
|
|
79
80
|
return this.global.entryLoading[uniqueKey];
|
|
80
81
|
} else {
|
|
81
|
-
const remoteInfo = (0,
|
|
82
|
+
const remoteInfo = (0, import_runtime2.getRemoteInfo)(remote);
|
|
82
83
|
const module2 = origin.moduleCache.get(remoteInfo.name);
|
|
83
|
-
return (0,
|
|
84
|
+
return (0, import_runtime2.getRemoteEntry)({
|
|
84
85
|
origin,
|
|
85
86
|
remoteInfo,
|
|
86
87
|
remoteEntryExports: module2 ? module2.remoteEntryExports : void 0
|
package/dist/plugin.js
CHANGED
|
@@ -27,6 +27,7 @@ module.exports = __toCommonJS(plugin_exports);
|
|
|
27
27
|
var import_sdk4 = require("@module-federation/sdk");
|
|
28
28
|
|
|
29
29
|
// src/common/runtime-utils.ts
|
|
30
|
+
var import_runtime = require("@module-federation/runtime");
|
|
30
31
|
var import_sdk = require("@module-federation/sdk");
|
|
31
32
|
var getPrefetchId = (id) => (0, import_sdk.encodeName)(`${id}/${import_sdk.MFPrefetchCommon.identifier}`);
|
|
32
33
|
var compatGetPrefetchId = (id) => (0, import_sdk.encodeName)(`${id}/VmokPrefetch`);
|
|
@@ -44,7 +45,7 @@ var getSignalFromManifest = (remoteSnapshot) => {
|
|
|
44
45
|
};
|
|
45
46
|
|
|
46
47
|
// src/prefetch.ts
|
|
47
|
-
var
|
|
48
|
+
var import_runtime2 = require("@module-federation/runtime");
|
|
48
49
|
var import_sdk2 = require("@module-federation/sdk");
|
|
49
50
|
globalThis.__FEDERATION__ ?? (globalThis.__FEDERATION__ = {});
|
|
50
51
|
var _a;
|
|
@@ -77,9 +78,9 @@ var MFDataPrefetch = class {
|
|
|
77
78
|
}
|
|
78
79
|
return this.global.entryLoading[uniqueKey];
|
|
79
80
|
} else {
|
|
80
|
-
const remoteInfo = (0,
|
|
81
|
+
const remoteInfo = (0, import_runtime2.getRemoteInfo)(remote);
|
|
81
82
|
const module2 = origin.moduleCache.get(remoteInfo.name);
|
|
82
|
-
return (0,
|
|
83
|
+
return (0, import_runtime2.getRemoteEntry)({
|
|
83
84
|
origin,
|
|
84
85
|
remoteInfo,
|
|
85
86
|
remoteEntryExports: module2 ? module2.remoteEntryExports : void 0
|
package/dist/react/index.js
CHANGED
|
@@ -32,18 +32,14 @@ var import_sdk = require("@module-federation/sdk");
|
|
|
32
32
|
var logger_default = new import_sdk.Logger("[Module Federation Data Prefetch]");
|
|
33
33
|
|
|
34
34
|
// src/prefetch.ts
|
|
35
|
-
var
|
|
35
|
+
var import_runtime2 = require("@module-federation/runtime");
|
|
36
36
|
var import_sdk3 = require("@module-federation/sdk");
|
|
37
37
|
|
|
38
38
|
// src/common/runtime-utils.ts
|
|
39
|
+
var import_runtime = require("@module-federation/runtime");
|
|
39
40
|
var import_sdk2 = require("@module-federation/sdk");
|
|
40
|
-
var getScope = (
|
|
41
|
-
|
|
42
|
-
if (idArray.length >= 2) {
|
|
43
|
-
idArray.pop();
|
|
44
|
-
}
|
|
45
|
-
const name = idArray.join("/");
|
|
46
|
-
return name;
|
|
41
|
+
var getScope = () => {
|
|
42
|
+
return (0, import_runtime.getInstance)().options.name;
|
|
47
43
|
};
|
|
48
44
|
var getPrefetchId = (id) => (0, import_sdk2.encodeName)(`${id}/${import_sdk2.MFPrefetchCommon.identifier}`);
|
|
49
45
|
var compatGetPrefetchId = (id) => (0, import_sdk2.encodeName)(`${id}/VmokPrefetch`);
|
|
@@ -80,9 +76,9 @@ var MFDataPrefetch = class {
|
|
|
80
76
|
}
|
|
81
77
|
return this.global.entryLoading[uniqueKey];
|
|
82
78
|
} else {
|
|
83
|
-
const remoteInfo = (0,
|
|
79
|
+
const remoteInfo = (0, import_runtime2.getRemoteInfo)(remote);
|
|
84
80
|
const module2 = origin.moduleCache.get(remoteInfo.name);
|
|
85
|
-
return (0,
|
|
81
|
+
return (0, import_runtime2.getRemoteEntry)({
|
|
86
82
|
origin,
|
|
87
83
|
remoteInfo,
|
|
88
84
|
remoteEntryExports: module2 ? module2.remoteEntryExports : void 0
|
|
@@ -190,8 +186,8 @@ var MFDataPrefetch = class {
|
|
|
190
186
|
|
|
191
187
|
// src/universal/index.ts
|
|
192
188
|
function prefetch(options) {
|
|
193
|
-
const { id, functionId } = options;
|
|
194
|
-
const mfScope = getScope(
|
|
189
|
+
const { id, functionId = "default" } = options;
|
|
190
|
+
const mfScope = getScope();
|
|
195
191
|
const prefetchInstance = MFDataPrefetch.getInstance(mfScope) || new MFDataPrefetch({
|
|
196
192
|
name: mfScope
|
|
197
193
|
});
|
|
@@ -234,7 +230,7 @@ var usePrefetch = (options) => {
|
|
|
234
230
|
id,
|
|
235
231
|
functionId
|
|
236
232
|
};
|
|
237
|
-
const mfScope = getScope(
|
|
233
|
+
const mfScope = getScope();
|
|
238
234
|
let state;
|
|
239
235
|
const prefetchResult = prefetch(options);
|
|
240
236
|
if (deferId) {
|
package/dist/universal/index.js
CHANGED
|
@@ -25,18 +25,14 @@ __export(universal_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(universal_exports);
|
|
26
26
|
|
|
27
27
|
// src/prefetch.ts
|
|
28
|
-
var
|
|
28
|
+
var import_runtime2 = require("@module-federation/runtime");
|
|
29
29
|
var import_sdk2 = require("@module-federation/sdk");
|
|
30
30
|
|
|
31
31
|
// src/common/runtime-utils.ts
|
|
32
|
+
var import_runtime = require("@module-federation/runtime");
|
|
32
33
|
var import_sdk = require("@module-federation/sdk");
|
|
33
|
-
var getScope = (
|
|
34
|
-
|
|
35
|
-
if (idArray.length >= 2) {
|
|
36
|
-
idArray.pop();
|
|
37
|
-
}
|
|
38
|
-
const name = idArray.join("/");
|
|
39
|
-
return name;
|
|
34
|
+
var getScope = () => {
|
|
35
|
+
return (0, import_runtime.getInstance)().options.name;
|
|
40
36
|
};
|
|
41
37
|
var getPrefetchId = (id) => (0, import_sdk.encodeName)(`${id}/${import_sdk.MFPrefetchCommon.identifier}`);
|
|
42
38
|
var compatGetPrefetchId = (id) => (0, import_sdk.encodeName)(`${id}/VmokPrefetch`);
|
|
@@ -73,9 +69,9 @@ var MFDataPrefetch = class {
|
|
|
73
69
|
}
|
|
74
70
|
return this.global.entryLoading[uniqueKey];
|
|
75
71
|
} else {
|
|
76
|
-
const remoteInfo = (0,
|
|
72
|
+
const remoteInfo = (0, import_runtime2.getRemoteInfo)(remote);
|
|
77
73
|
const module2 = origin.moduleCache.get(remoteInfo.name);
|
|
78
|
-
return (0,
|
|
74
|
+
return (0, import_runtime2.getRemoteEntry)({
|
|
79
75
|
origin,
|
|
80
76
|
remoteInfo,
|
|
81
77
|
remoteEntryExports: module2 ? module2.remoteEntryExports : void 0
|
|
@@ -183,8 +179,8 @@ var MFDataPrefetch = class {
|
|
|
183
179
|
|
|
184
180
|
// src/universal/index.ts
|
|
185
181
|
function prefetch(options) {
|
|
186
|
-
const { id, functionId } = options;
|
|
187
|
-
const mfScope = getScope(
|
|
182
|
+
const { id, functionId = "default" } = options;
|
|
183
|
+
const mfScope = getScope();
|
|
188
184
|
const prefetchInstance = MFDataPrefetch.getInstance(mfScope) || new MFDataPrefetch({
|
|
189
185
|
name: mfScope
|
|
190
186
|
});
|
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-20240918080432",
|
|
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-20240918080432",
|
|
89
|
+
"@module-federation/runtime": "0.0.0-next-20240918080432"
|
|
90
90
|
},
|
|
91
91
|
"scripts": {
|
|
92
92
|
"dev": "cross-env WATCH=true tsup",
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
+
import { getInstance } from '@module-federation/runtime';
|
|
1
2
|
import {
|
|
2
3
|
encodeName,
|
|
3
4
|
ModuleInfo,
|
|
4
5
|
MFPrefetchCommon,
|
|
5
6
|
} from '@module-federation/sdk';
|
|
6
7
|
|
|
7
|
-
export const getScope = (
|
|
8
|
-
|
|
9
|
-
if (idArray.length >= 2) {
|
|
10
|
-
idArray.pop();
|
|
11
|
-
}
|
|
12
|
-
const name = idArray.join('/');
|
|
13
|
-
return name;
|
|
8
|
+
export const getScope = (): string => {
|
|
9
|
+
return getInstance()!.options.name;
|
|
14
10
|
};
|
|
15
11
|
|
|
16
12
|
export const getPrefetchId = (id: string): string =>
|
package/src/react/hooks.ts
CHANGED
package/src/universal/index.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { MFDataPrefetch, type prefetchOptions } from '../prefetch';
|
|
|
2
2
|
import { getScope } from '../common/runtime-utils';
|
|
3
3
|
|
|
4
4
|
export function prefetch(options: prefetchOptions): Promise<any> {
|
|
5
|
-
const { id, functionId } = options;
|
|
6
|
-
const mfScope = getScope(
|
|
5
|
+
const { id, functionId = 'default' } = options;
|
|
6
|
+
const mfScope = getScope();
|
|
7
7
|
|
|
8
8
|
const prefetchInstance =
|
|
9
9
|
MFDataPrefetch.getInstance(mfScope) ||
|