@module-federation/data-prefetch 0.0.0-next-20240911025149 → 0.0.0-next-20240911083839
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 +10 -7
- package/dist/esm/cli/index.js +10 -7
- package/package.json +3 -3
- package/src/cli/index.ts +11 -7
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-20240911083839
|
|
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-20240911083839
|
|
9
|
+
- @module-federation/sdk@0.0.0-next-20240911083839
|
package/dist/cli/index.js
CHANGED
|
@@ -77,6 +77,7 @@ var PrefetchPlugin = class {
|
|
|
77
77
|
this._reWriteExports = "";
|
|
78
78
|
}
|
|
79
79
|
apply(compiler) {
|
|
80
|
+
var _a, _b;
|
|
80
81
|
const { name, exposes } = this.options;
|
|
81
82
|
if (!exposes) {
|
|
82
83
|
return;
|
|
@@ -88,12 +89,14 @@ var PrefetchPlugin = class {
|
|
|
88
89
|
if (!Array.isArray(runtimePlugins)) {
|
|
89
90
|
this.options.runtimePlugins = [];
|
|
90
91
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
)
|
|
92
|
+
const runtimePath = import_path2.default.resolve(__dirname, "../esm/plugin.js");
|
|
93
|
+
const sharedPath = import_path2.default.resolve(__dirname, "../esm/shared/index.js");
|
|
94
|
+
if (!((_a = this.options.runtimePlugins) == null ? void 0 : _a.includes(runtimePath))) {
|
|
95
|
+
this.options.runtimePlugins.push(runtimePath);
|
|
96
|
+
}
|
|
97
|
+
if (!((_b = this.options.runtimePlugins) == null ? void 0 : _b.includes(sharedPath))) {
|
|
98
|
+
this.options.runtimePlugins.push(sharedPath);
|
|
99
|
+
}
|
|
97
100
|
const encodedName = (0, import_sdk2.encodeName)(name);
|
|
98
101
|
const asyncEntryPath = import_path2.default.resolve(
|
|
99
102
|
compiler.options.context,
|
|
@@ -175,7 +178,7 @@ var PrefetchPlugin = class {
|
|
|
175
178
|
`${federationGlobal}.prefetch = injectPrefetch`
|
|
176
179
|
]) : "",
|
|
177
180
|
Template.indent([
|
|
178
|
-
`if(
|
|
181
|
+
`if(!${federationGlobal}.isMFRemote && ${federationGlobal}.prefetch){`,
|
|
179
182
|
`${federationGlobal}.prefetch()`,
|
|
180
183
|
"}"
|
|
181
184
|
])
|
package/dist/esm/cli/index.js
CHANGED
|
@@ -52,6 +52,7 @@ var PrefetchPlugin = class {
|
|
|
52
52
|
this._reWriteExports = "";
|
|
53
53
|
}
|
|
54
54
|
apply(compiler) {
|
|
55
|
+
var _a, _b;
|
|
55
56
|
const { name, exposes } = this.options;
|
|
56
57
|
if (!exposes) {
|
|
57
58
|
return;
|
|
@@ -63,12 +64,14 @@ var PrefetchPlugin = class {
|
|
|
63
64
|
if (!Array.isArray(runtimePlugins)) {
|
|
64
65
|
this.options.runtimePlugins = [];
|
|
65
66
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
)
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
)
|
|
67
|
+
const runtimePath = path2.resolve(__dirname, "../esm/plugin.js");
|
|
68
|
+
const sharedPath = path2.resolve(__dirname, "../esm/shared/index.js");
|
|
69
|
+
if (!((_a = this.options.runtimePlugins) == null ? void 0 : _a.includes(runtimePath))) {
|
|
70
|
+
this.options.runtimePlugins.push(runtimePath);
|
|
71
|
+
}
|
|
72
|
+
if (!((_b = this.options.runtimePlugins) == null ? void 0 : _b.includes(sharedPath))) {
|
|
73
|
+
this.options.runtimePlugins.push(sharedPath);
|
|
74
|
+
}
|
|
72
75
|
const encodedName = encodeName(name);
|
|
73
76
|
const asyncEntryPath = path2.resolve(
|
|
74
77
|
compiler.options.context,
|
|
@@ -150,7 +153,7 @@ var PrefetchPlugin = class {
|
|
|
150
153
|
`${federationGlobal}.prefetch = injectPrefetch`
|
|
151
154
|
]) : "",
|
|
152
155
|
Template.indent([
|
|
153
|
-
`if(
|
|
156
|
+
`if(!${federationGlobal}.isMFRemote && ${federationGlobal}.prefetch){`,
|
|
154
157
|
`${federationGlobal}.prefetch()`,
|
|
155
158
|
"}"
|
|
156
159
|
])
|
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-20240911083839",
|
|
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-20240911083839",
|
|
89
|
+
"@module-federation/runtime": "0.0.0-next-20240911083839"
|
|
90
90
|
},
|
|
91
91
|
"scripts": {
|
|
92
92
|
"dev": "cross-env WATCH=true tsup",
|
package/src/cli/index.ts
CHANGED
|
@@ -46,12 +46,16 @@ export class PrefetchPlugin implements WebpackPluginInstance {
|
|
|
46
46
|
if (!Array.isArray(runtimePlugins)) {
|
|
47
47
|
this.options.runtimePlugins = [];
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
);
|
|
52
|
-
this.options.runtimePlugins
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
|
|
50
|
+
const runtimePath = path.resolve(__dirname, '../esm/plugin.js');
|
|
51
|
+
const sharedPath = path.resolve(__dirname, '../esm/shared/index.js');
|
|
52
|
+
if (!this.options.runtimePlugins?.includes(runtimePath)) {
|
|
53
|
+
this.options.runtimePlugins!.push(runtimePath);
|
|
54
|
+
}
|
|
55
|
+
if (!this.options.runtimePlugins?.includes(sharedPath)) {
|
|
56
|
+
this.options.runtimePlugins!.push(sharedPath);
|
|
57
|
+
}
|
|
58
|
+
|
|
55
59
|
const encodedName = encodeName(name as string);
|
|
56
60
|
const asyncEntryPath = path.resolve(
|
|
57
61
|
compiler.options.context,
|
|
@@ -144,7 +148,7 @@ export class PrefetchPlugin implements WebpackPluginInstance {
|
|
|
144
148
|
])
|
|
145
149
|
: '',
|
|
146
150
|
Template.indent([
|
|
147
|
-
`if(
|
|
151
|
+
`if(!${federationGlobal}.isMFRemote && ${federationGlobal}.prefetch){`,
|
|
148
152
|
`${federationGlobal}.prefetch()`,
|
|
149
153
|
'}',
|
|
150
154
|
]),
|