@umijs/plugins 4.0.0-canary.20240605.1 → 4.0.0-canary.20240624.1
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/dist/initial-state.js +1 -1
- package/dist/layout.js +2 -8
- package/dist/mf-v2.d.ts +52 -0
- package/dist/mf-v2.js +402 -0
- package/dist/mf.js +25 -72
- package/dist/qiankun/master.js +0 -10
- package/dist/qiankun/slave.js +6 -12
- package/dist/react-query.js +135 -55
- package/dist/utils/npmClient.d.ts +2 -0
- package/dist/utils/npmClient.js +45 -0
- package/libs/qiankun/master/MicroApp.tsx +9 -6
- package/libs/qiankun/master/masterRuntimePlugin.tsx +0 -8
- package/libs/qiankun/slave/slaveRuntimePlugin.ts +0 -4
- package/package.json +4 -3
package/dist/initial-state.js
CHANGED
|
@@ -65,7 +65,7 @@ export default function InitialStateProvider(props: any) {
|
|
|
65
65
|
appLoaded.current = true;
|
|
66
66
|
}
|
|
67
67
|
}, [loading]);
|
|
68
|
-
if (loading && !appLoaded.current
|
|
68
|
+
if (loading && !appLoaded.current) {
|
|
69
69
|
return <Loading />;
|
|
70
70
|
}
|
|
71
71
|
return props.children;
|
package/dist/layout.js
CHANGED
|
@@ -36,6 +36,7 @@ var import_fs = require("fs");
|
|
|
36
36
|
var import_path = require("path");
|
|
37
37
|
var import_umi = require("umi");
|
|
38
38
|
var import_plugin_utils = require("umi/plugin-utils");
|
|
39
|
+
var import_npmClient = require("./utils/npmClient");
|
|
39
40
|
var import_resolveProjectDep = require("./utils/resolveProjectDep");
|
|
40
41
|
var import_withTmpPath = require("./utils/withTmpPath");
|
|
41
42
|
var antIconsPath = (0, import_plugin_utils.winPath)(
|
|
@@ -118,14 +119,7 @@ var layout_default = (api) => {
|
|
|
118
119
|
return memo;
|
|
119
120
|
});
|
|
120
121
|
api.onGenerateFiles(() => {
|
|
121
|
-
|
|
122
|
-
let realNpmClient = api.appData.npmClient;
|
|
123
|
-
if (api.appData.npmClient === import_plugin_utils.NpmClientEnum.tnpm && ((_a = api.pkg.tnpm) == null ? void 0 : _a.mode) && [import_plugin_utils.NpmClientEnum.npm, import_plugin_utils.NpmClientEnum.yarn].includes(api.pkg.tnpm.mode)) {
|
|
124
|
-
realNpmClient = api.pkg.tnpm.mode;
|
|
125
|
-
}
|
|
126
|
-
const isFlattedDepsDir = [import_plugin_utils.NpmClientEnum.npm, import_plugin_utils.NpmClientEnum.yarn].includes(
|
|
127
|
-
realNpmClient
|
|
128
|
-
);
|
|
122
|
+
const isFlattedDepsDir = (0, import_npmClient.isFlattedNodeModulesDir)(api);
|
|
129
123
|
const PKG_TYPE_REFERENCE = `
|
|
130
124
|
/// <reference types="${isFlattedDepsDir ? ANT_PRO_COMPONENT : resolvedPkgPath}" />
|
|
131
125
|
${isFlattedDepsDir ? '/// <reference types="antd" />' : ""}
|
package/dist/mf-v2.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { zod as z } from '@umijs/utils';
|
|
2
|
+
import { IApi } from 'umi';
|
|
3
|
+
export declare enum EVersion {
|
|
4
|
+
v1 = "v1",
|
|
5
|
+
v2 = "v2"
|
|
6
|
+
}
|
|
7
|
+
interface IOptions {
|
|
8
|
+
standalone?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function configSchema(zod: typeof z): z.ZodObject<{
|
|
11
|
+
name: z.ZodOptional<z.ZodString>;
|
|
12
|
+
remotes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
13
|
+
name: z.ZodString;
|
|
14
|
+
entry: z.ZodString;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
name: string;
|
|
17
|
+
entry: string;
|
|
18
|
+
}, {
|
|
19
|
+
name: string;
|
|
20
|
+
entry: string;
|
|
21
|
+
}>, "many">>;
|
|
22
|
+
shared: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
23
|
+
library: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
24
|
+
remoteHash: z.ZodOptional<z.ZodBoolean>;
|
|
25
|
+
version: z.ZodOptional<z.ZodEnum<[EVersion.v1, EVersion.v2]>>;
|
|
26
|
+
overrideConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
name?: string | undefined;
|
|
29
|
+
remotes?: {
|
|
30
|
+
name: string;
|
|
31
|
+
entry: string;
|
|
32
|
+
}[] | undefined;
|
|
33
|
+
shared?: Record<string, any> | undefined;
|
|
34
|
+
library?: Record<string, any> | undefined;
|
|
35
|
+
remoteHash?: boolean | undefined;
|
|
36
|
+
version?: EVersion | undefined;
|
|
37
|
+
overrideConfig?: Record<string, any> | undefined;
|
|
38
|
+
}, {
|
|
39
|
+
name?: string | undefined;
|
|
40
|
+
remotes?: {
|
|
41
|
+
name: string;
|
|
42
|
+
entry: string;
|
|
43
|
+
}[] | undefined;
|
|
44
|
+
shared?: Record<string, any> | undefined;
|
|
45
|
+
library?: Record<string, any> | undefined;
|
|
46
|
+
remoteHash?: boolean | undefined;
|
|
47
|
+
version?: EVersion | undefined;
|
|
48
|
+
overrideConfig?: Record<string, any> | undefined;
|
|
49
|
+
}>;
|
|
50
|
+
declare const _default: (api: IApi, options?: IOptions) => void;
|
|
51
|
+
export default _default;
|
|
52
|
+
export declare function isValidIdentifyName(name: string): boolean;
|
package/dist/mf-v2.js
ADDED
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/mf-v2.ts
|
|
30
|
+
var mf_v2_exports = {};
|
|
31
|
+
__export(mf_v2_exports, {
|
|
32
|
+
EVersion: () => EVersion,
|
|
33
|
+
configSchema: () => configSchema,
|
|
34
|
+
default: () => mf_v2_default,
|
|
35
|
+
isValidIdentifyName: () => isValidIdentifyName
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(mf_v2_exports);
|
|
38
|
+
var import_bundler_utils = require("@umijs/bundler-utils");
|
|
39
|
+
var import_utils = require("@umijs/utils");
|
|
40
|
+
var import_fs = require("fs");
|
|
41
|
+
var import_path = __toESM(require("path"));
|
|
42
|
+
var { isEmpty } = import_utils.lodash;
|
|
43
|
+
var EVersion = /* @__PURE__ */ ((EVersion2) => {
|
|
44
|
+
EVersion2["v1"] = "v1";
|
|
45
|
+
EVersion2["v2"] = "v2";
|
|
46
|
+
return EVersion2;
|
|
47
|
+
})(EVersion || {});
|
|
48
|
+
var LOGGER_LABEL = import_utils.chalk.bold.blue("[module-federation-v2]");
|
|
49
|
+
function configSchema(zod) {
|
|
50
|
+
return zod.object({
|
|
51
|
+
name: zod.string(),
|
|
52
|
+
remotes: zod.array(
|
|
53
|
+
zod.object({
|
|
54
|
+
name: zod.string(),
|
|
55
|
+
entry: zod.string()
|
|
56
|
+
})
|
|
57
|
+
),
|
|
58
|
+
shared: zod.record(zod.any()),
|
|
59
|
+
library: zod.record(zod.any()),
|
|
60
|
+
remoteHash: zod.boolean(),
|
|
61
|
+
version: zod.enum(["v1" /* v1 */, "v2" /* v2 */]),
|
|
62
|
+
overrideConfig: zod.record(zod.any())
|
|
63
|
+
}).partial();
|
|
64
|
+
}
|
|
65
|
+
var mf_v2_default = (api, options) => {
|
|
66
|
+
const { standalone = true } = options || {};
|
|
67
|
+
if (standalone) {
|
|
68
|
+
api.describe({
|
|
69
|
+
key: "mfV2",
|
|
70
|
+
enableBy: api.EnableBy.config,
|
|
71
|
+
config: {
|
|
72
|
+
schema({ zod }) {
|
|
73
|
+
return configSchema(zod);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
let bundlerWebpackPath;
|
|
79
|
+
try {
|
|
80
|
+
bundlerWebpackPath = import_path.default.dirname(
|
|
81
|
+
require.resolve("@umijs/bundler-webpack/package.json")
|
|
82
|
+
);
|
|
83
|
+
} catch {
|
|
84
|
+
}
|
|
85
|
+
api.onStart(() => {
|
|
86
|
+
if (!bundlerWebpackPath) {
|
|
87
|
+
throw new Error(
|
|
88
|
+
`Not found '@umijs/bundler-webpack', please check dependencies`
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
const infoMsg = `Using module federation v2`;
|
|
92
|
+
console.log(`${LOGGER_LABEL} ${import_utils.chalk.gray(infoMsg)}`);
|
|
93
|
+
process.env.FEDERATION_WEBPACK_PATH = import_path.default.join(
|
|
94
|
+
api.paths.absTmpPath,
|
|
95
|
+
`plugin-${api.plugin.key}`,
|
|
96
|
+
"webpack/lib/index.js"
|
|
97
|
+
);
|
|
98
|
+
});
|
|
99
|
+
api.onGenerateFiles(({ isFirstTime }) => {
|
|
100
|
+
if (!isFirstTime || !bundlerWebpackPath) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const webpackPath = import_path.default.join(bundlerWebpackPath, "compiled/webpack");
|
|
104
|
+
const deepImportPath = import_path.default.join(webpackPath, "deepImports.json");
|
|
105
|
+
const deepImports = require(deepImportPath);
|
|
106
|
+
deepImports.forEach((p) => {
|
|
107
|
+
const content = `
|
|
108
|
+
module.exports = require('${p}')
|
|
109
|
+
`.trimStart();
|
|
110
|
+
api.writeTmpFile({
|
|
111
|
+
path: `${p}.js`,
|
|
112
|
+
content
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
const entryContent = `module.exports = require('webpack')`;
|
|
116
|
+
api.writeTmpFile({
|
|
117
|
+
path: "webpack/lib/index.js",
|
|
118
|
+
content: entryContent
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
const getConfig = () => {
|
|
122
|
+
const key = api.plugin.key;
|
|
123
|
+
const config = api.userConfig[key] || api.config[key] || {};
|
|
124
|
+
return config;
|
|
125
|
+
};
|
|
126
|
+
const constructExposes = async () => {
|
|
127
|
+
const exposes = {};
|
|
128
|
+
const exposesPath = import_path.default.join(api.paths.absSrcPath, "exposes");
|
|
129
|
+
if (!(0, import_fs.existsSync)(exposesPath)) {
|
|
130
|
+
return exposes;
|
|
131
|
+
}
|
|
132
|
+
const dir = (0, import_fs.opendirSync)(exposesPath);
|
|
133
|
+
for await (const dirent of dir) {
|
|
134
|
+
if (dirent.isDirectory()) {
|
|
135
|
+
exposes[`./${dirent.name}`] = (0, import_utils.winPath)(
|
|
136
|
+
import_path.default.join(exposesPath, dirent.name)
|
|
137
|
+
);
|
|
138
|
+
} else {
|
|
139
|
+
const warningMsg = `${dirent.name} is not a directory, ignore in ModuleFederation expose`;
|
|
140
|
+
console.log(`${LOGGER_LABEL} ${import_utils.chalk.yellow(warningMsg)}`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return exposes;
|
|
144
|
+
};
|
|
145
|
+
const formatRemotes = (config) => {
|
|
146
|
+
const { remotes = [] } = config;
|
|
147
|
+
const memo = {};
|
|
148
|
+
remotes.forEach((remote) => {
|
|
149
|
+
const { name, entry } = remote;
|
|
150
|
+
if (!(name == null ? void 0 : name.length)) {
|
|
151
|
+
const errorMsg = `remote name is required`;
|
|
152
|
+
console.log(`${LOGGER_LABEL} ${import_utils.chalk.red(errorMsg)}`);
|
|
153
|
+
throw new Error(errorMsg);
|
|
154
|
+
}
|
|
155
|
+
const getFormatEntry = () => {
|
|
156
|
+
if (!(entry == null ? void 0 : entry.length)) {
|
|
157
|
+
const errorMsg = `you should provider entry for remote ${name}`;
|
|
158
|
+
console.log(`${LOGGER_LABEL} ${import_utils.chalk.red(errorMsg)}`);
|
|
159
|
+
throw new Error(errorMsg);
|
|
160
|
+
}
|
|
161
|
+
const hasAt = entry.includes("@");
|
|
162
|
+
if (hasAt) {
|
|
163
|
+
return entry;
|
|
164
|
+
}
|
|
165
|
+
return `${remote.name}@${entry}`;
|
|
166
|
+
};
|
|
167
|
+
const finalName = name;
|
|
168
|
+
const finalEntry = getFormatEntry();
|
|
169
|
+
if (memo[finalName]) {
|
|
170
|
+
const errorMsg = `remote ${finalName} is already exists, please check your config`;
|
|
171
|
+
console.log(`${LOGGER_LABEL} ${import_utils.chalk.red(errorMsg)}`);
|
|
172
|
+
throw new Error(errorMsg);
|
|
173
|
+
}
|
|
174
|
+
memo[finalName] = finalEntry;
|
|
175
|
+
});
|
|
176
|
+
return memo;
|
|
177
|
+
};
|
|
178
|
+
const getShared = (config) => {
|
|
179
|
+
const { shared = {} } = config;
|
|
180
|
+
return shared;
|
|
181
|
+
};
|
|
182
|
+
const mfAsyncEntryFileName = "asyncEntry.ts";
|
|
183
|
+
const getAppEntryFile = () => {
|
|
184
|
+
const entryFile = import_path.default.join(
|
|
185
|
+
api.paths.absTmpPath,
|
|
186
|
+
`plugin-${api.plugin.key}`,
|
|
187
|
+
mfAsyncEntryFileName
|
|
188
|
+
);
|
|
189
|
+
return (0, import_utils.winPath)(entryFile);
|
|
190
|
+
};
|
|
191
|
+
const changeUmiEntry = (config) => {
|
|
192
|
+
const { entry } = config;
|
|
193
|
+
const asyncEntryPath = getAppEntryFile();
|
|
194
|
+
if (entry.umi) {
|
|
195
|
+
if (typeof entry.umi === "string") {
|
|
196
|
+
entry.umi = asyncEntryPath;
|
|
197
|
+
} else if (Array.isArray(entry.umi)) {
|
|
198
|
+
const i = entry.umi.findIndex((f) => f.endsWith("umi.ts"));
|
|
199
|
+
if (i >= 0) {
|
|
200
|
+
entry.umi[i] = asyncEntryPath;
|
|
201
|
+
} else {
|
|
202
|
+
const warnMsg = `Not found umi entry in 'entry.umi' ${JSON.stringify(
|
|
203
|
+
entry.umi
|
|
204
|
+
)}`;
|
|
205
|
+
console.log(`${LOGGER_LABEL} ${import_utils.chalk.yellow(warnMsg)}`);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
} else {
|
|
209
|
+
const warnMsg = `umi entry not found`;
|
|
210
|
+
console.log(`${LOGGER_LABEL} ${import_utils.chalk.yellow(warnMsg)}`);
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
const getMfName = (config) => {
|
|
214
|
+
const name = config.name;
|
|
215
|
+
const packageName = api.pkg.name;
|
|
216
|
+
const finalName = name || packageName;
|
|
217
|
+
if (!(finalName == null ? void 0 : finalName.length)) {
|
|
218
|
+
const errorMsg = `module federation name is not defined , please set 'name' in mf config or 'name' in package.json`;
|
|
219
|
+
console.log(`${LOGGER_LABEL} ${import_utils.chalk.red(errorMsg)}`);
|
|
220
|
+
throw new Error(errorMsg);
|
|
221
|
+
}
|
|
222
|
+
if (!isValidIdentifyName(finalName)) {
|
|
223
|
+
throw new Error(
|
|
224
|
+
`module federation name '${finalName}' is not valid javascript identifier.`
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
return finalName;
|
|
228
|
+
};
|
|
229
|
+
api.modifyWebpackConfig(async (config) => {
|
|
230
|
+
const pluginConfig = getConfig();
|
|
231
|
+
const exposes = await constructExposes();
|
|
232
|
+
const remotes = formatRemotes(pluginConfig);
|
|
233
|
+
const shared = getShared(pluginConfig);
|
|
234
|
+
if (isEmpty(remotes) && isEmpty(exposes)) {
|
|
235
|
+
const warnMsg = `ModuleFederation exposes and remotes are empty, plugin will not work`;
|
|
236
|
+
console.log(`${LOGGER_LABEL} ${import_utils.chalk.yellow(warnMsg)}`);
|
|
237
|
+
return config;
|
|
238
|
+
}
|
|
239
|
+
if (api.env === "production" || !api.config.mfsu) {
|
|
240
|
+
changeUmiEntry(config);
|
|
241
|
+
}
|
|
242
|
+
const name = getMfName(pluginConfig);
|
|
243
|
+
const useHash = typeof pluginConfig.remoteHash === "boolean" ? pluginConfig.remoteHash : api.config.hash && api.env !== "development";
|
|
244
|
+
const mfConfig = {
|
|
245
|
+
name,
|
|
246
|
+
remotes,
|
|
247
|
+
filename: useHash ? "remote.[contenthash:8].js" : "remote.js",
|
|
248
|
+
exposes,
|
|
249
|
+
shared,
|
|
250
|
+
library: pluginConfig.library,
|
|
251
|
+
...pluginConfig.overrideConfig || {}
|
|
252
|
+
};
|
|
253
|
+
const checkConfig = () => {
|
|
254
|
+
if (api.config.mfsu) {
|
|
255
|
+
console.log(
|
|
256
|
+
`${LOGGER_LABEL} cannot use mfsu with module federation, please disable 'mfsu' in config (e.g. 'mfsu: false')`
|
|
257
|
+
);
|
|
258
|
+
throw new Error(`mfsu cannot use with module federation`);
|
|
259
|
+
}
|
|
260
|
+
if (!isEmpty(mfConfig.exposes)) {
|
|
261
|
+
const jsMinifier = api.config.jsMinifier || "esbuild";
|
|
262
|
+
if (jsMinifier === "esbuild") {
|
|
263
|
+
const library = pluginConfig.library;
|
|
264
|
+
if (!(library == null ? void 0 : library.type)) {
|
|
265
|
+
const errorMsg = `mf config 'library.type' is required when not set 'jsMinifier' or use 'esbuild'`;
|
|
266
|
+
const recommandMsg = `please set 'library.type' or use 'jsMinifier: terser' (e.g. 'library: { type: "window", name: "..." }')`;
|
|
267
|
+
const finalMsg = `${errorMsg}, ${recommandMsg}`;
|
|
268
|
+
console.log(`${LOGGER_LABEL} ${import_utils.chalk.red(finalMsg)}`);
|
|
269
|
+
throw new Error(finalMsg);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
checkConfig();
|
|
275
|
+
const {
|
|
276
|
+
ModuleFederationPlugin
|
|
277
|
+
} = require("@module-federation/enhanced/webpack");
|
|
278
|
+
config.plugins.push(new ModuleFederationPlugin(mfConfig));
|
|
279
|
+
api.logger.debug(
|
|
280
|
+
`ModuleFederationPlugin V2 is enabled with config ${JSON.stringify(
|
|
281
|
+
mfConfig
|
|
282
|
+
)}`
|
|
283
|
+
);
|
|
284
|
+
return config;
|
|
285
|
+
});
|
|
286
|
+
api.register({
|
|
287
|
+
key: "onGenerateFiles",
|
|
288
|
+
stage: 10002,
|
|
289
|
+
fn: async () => {
|
|
290
|
+
const entry = import_path.default.join(api.paths.absTmpPath, "umi.ts");
|
|
291
|
+
const content = (0, import_fs.readFileSync)(entry, "utf-8");
|
|
292
|
+
const [_imports, exports] = await (0, import_bundler_utils.parseModule)({ content, path: entry });
|
|
293
|
+
const mfEntryContent = [];
|
|
294
|
+
let hasDefaultExport = false;
|
|
295
|
+
if (exports.length) {
|
|
296
|
+
mfEntryContent.push(
|
|
297
|
+
`const umiExports = await import('${(0, import_utils.winPath)(entry)}')`
|
|
298
|
+
);
|
|
299
|
+
for (const exportName of exports) {
|
|
300
|
+
if (exportName === "default") {
|
|
301
|
+
hasDefaultExport = true;
|
|
302
|
+
mfEntryContent.push(`export default umiExports.${exportName}`);
|
|
303
|
+
} else {
|
|
304
|
+
mfEntryContent.push(
|
|
305
|
+
`export const ${exportName} = umiExports.${exportName}`
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
} else {
|
|
310
|
+
mfEntryContent.push(`import('${(0, import_utils.winPath)(entry)}')`);
|
|
311
|
+
}
|
|
312
|
+
if (!hasDefaultExport) {
|
|
313
|
+
mfEntryContent.push("export default 1");
|
|
314
|
+
}
|
|
315
|
+
api.writeTmpFile({
|
|
316
|
+
content: mfEntryContent.join("\n"),
|
|
317
|
+
path: mfAsyncEntryFileName
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
api.modifyTSConfig((memo) => {
|
|
322
|
+
const typesDir = (0, import_utils.winPath)(import_path.default.join(api.cwd, "./@mf-types/*"));
|
|
323
|
+
memo.compilerOptions.paths["*"] = [typesDir];
|
|
324
|
+
return memo;
|
|
325
|
+
});
|
|
326
|
+
};
|
|
327
|
+
function isValidIdentifyName(name) {
|
|
328
|
+
const reservedKeywords = [
|
|
329
|
+
"abstract",
|
|
330
|
+
"await",
|
|
331
|
+
"boolean",
|
|
332
|
+
"break",
|
|
333
|
+
"byte",
|
|
334
|
+
"case",
|
|
335
|
+
"catch",
|
|
336
|
+
"char",
|
|
337
|
+
"class",
|
|
338
|
+
"const",
|
|
339
|
+
"continue",
|
|
340
|
+
"debugger",
|
|
341
|
+
"default",
|
|
342
|
+
"delete",
|
|
343
|
+
"do",
|
|
344
|
+
"double",
|
|
345
|
+
"else",
|
|
346
|
+
"enum",
|
|
347
|
+
"export",
|
|
348
|
+
"extends",
|
|
349
|
+
"false",
|
|
350
|
+
"final",
|
|
351
|
+
"finally",
|
|
352
|
+
"float",
|
|
353
|
+
"for",
|
|
354
|
+
"function",
|
|
355
|
+
"goto",
|
|
356
|
+
"if",
|
|
357
|
+
"implements",
|
|
358
|
+
"import",
|
|
359
|
+
"in",
|
|
360
|
+
"instanceof",
|
|
361
|
+
"int",
|
|
362
|
+
"interface",
|
|
363
|
+
"let",
|
|
364
|
+
"long",
|
|
365
|
+
"native",
|
|
366
|
+
"new",
|
|
367
|
+
"null",
|
|
368
|
+
"package",
|
|
369
|
+
"private",
|
|
370
|
+
"protected",
|
|
371
|
+
"public",
|
|
372
|
+
"return",
|
|
373
|
+
"short",
|
|
374
|
+
"static",
|
|
375
|
+
"super",
|
|
376
|
+
"switch",
|
|
377
|
+
"synchronized",
|
|
378
|
+
"this",
|
|
379
|
+
"throw",
|
|
380
|
+
"transient",
|
|
381
|
+
"true",
|
|
382
|
+
"try",
|
|
383
|
+
"typeof",
|
|
384
|
+
"var",
|
|
385
|
+
"void",
|
|
386
|
+
"volatile",
|
|
387
|
+
"while",
|
|
388
|
+
"with",
|
|
389
|
+
"yield"
|
|
390
|
+
];
|
|
391
|
+
const regexIdentifierName = /^(?:[$_\p{ID_Start}])(?:[$_\u200C\u200D\p{ID_Continue}])*$/u;
|
|
392
|
+
if (reservedKeywords.includes(name) || !regexIdentifierName.test(name)) {
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
return true;
|
|
396
|
+
}
|
|
397
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
398
|
+
0 && (module.exports = {
|
|
399
|
+
EVersion,
|
|
400
|
+
configSchema,
|
|
401
|
+
isValidIdentifyName
|
|
402
|
+
});
|
package/dist/mf.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
17
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
28
|
|
|
19
29
|
// src/mf.ts
|
|
@@ -27,16 +37,23 @@ var import_fs = require("fs");
|
|
|
27
37
|
var import_path = require("path");
|
|
28
38
|
var import_plugin_utils = require("umi/plugin-utils");
|
|
29
39
|
var import_constants = require("./constants");
|
|
40
|
+
var import_mf_v2 = __toESM(require("./mf-v2"));
|
|
30
41
|
var import_mfUtils = require("./utils/mfUtils");
|
|
31
42
|
var { isEmpty } = import_plugin_utils.lodash;
|
|
32
43
|
var mfSetupPathFileName = "_mf_setup-public-path.js";
|
|
33
44
|
var mfAsyncEntryFileName = "asyncEntry.ts";
|
|
34
45
|
var MF_TEMPLATES_DIR = (0, import_path.join)(import_constants.TEMPLATES_DIR, "mf");
|
|
35
46
|
function mf(api) {
|
|
47
|
+
var _a, _b;
|
|
36
48
|
api.describe({
|
|
37
49
|
key: "mf",
|
|
38
50
|
config: {
|
|
39
51
|
schema({ zod }) {
|
|
52
|
+
var _a2;
|
|
53
|
+
const useVersion = (_a2 = api.userConfig.mf) == null ? void 0 : _a2.version;
|
|
54
|
+
if (useVersion === import_mf_v2.EVersion.v2) {
|
|
55
|
+
return (0, import_mf_v2.configSchema)(zod);
|
|
56
|
+
}
|
|
40
57
|
return zod.object({
|
|
41
58
|
name: zod.string(),
|
|
42
59
|
remotes: zod.array(
|
|
@@ -51,12 +68,18 @@ function mf(api) {
|
|
|
51
68
|
),
|
|
52
69
|
shared: zod.record(zod.any()),
|
|
53
70
|
library: zod.record(zod.any()),
|
|
54
|
-
remoteHash: zod.boolean()
|
|
71
|
+
remoteHash: zod.boolean(),
|
|
72
|
+
version: zod.enum([import_mf_v2.EVersion.v1, import_mf_v2.EVersion.v2])
|
|
55
73
|
}).partial();
|
|
56
74
|
}
|
|
57
75
|
},
|
|
58
76
|
enableBy: api.EnableBy.config
|
|
59
77
|
});
|
|
78
|
+
const useV2 = ((_a = api.userConfig.mf) == null ? void 0 : _a.version) === import_mf_v2.EVersion.v2 || ((_b = api.config.mf) == null ? void 0 : _b.version) === import_mf_v2.EVersion.v2;
|
|
79
|
+
if (useV2) {
|
|
80
|
+
(0, import_mf_v2.default)(api, { standalone: false });
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
60
83
|
api.modifyWebpackConfig(async (config, { webpack }) => {
|
|
61
84
|
const exposes = await constructExposes();
|
|
62
85
|
const remotes = formatRemotes();
|
|
@@ -249,7 +272,7 @@ function mf(api) {
|
|
|
249
272
|
`module federation name is not defined , "unNamedMF" will be used`
|
|
250
273
|
);
|
|
251
274
|
}
|
|
252
|
-
if (!isValidIdentifyName(name)) {
|
|
275
|
+
if (!(0, import_mf_v2.isValidIdentifyName)(name)) {
|
|
253
276
|
throw new Error(
|
|
254
277
|
`module federation name '${name}' is not valid javascript identifier.`
|
|
255
278
|
);
|
|
@@ -285,74 +308,4 @@ function mf(api) {
|
|
|
285
308
|
function addMFEntry(config, mfName2, path) {
|
|
286
309
|
config.entry[mfName2] = path;
|
|
287
310
|
}
|
|
288
|
-
function isValidIdentifyName(name) {
|
|
289
|
-
const reservedKeywords = [
|
|
290
|
-
"abstract",
|
|
291
|
-
"await",
|
|
292
|
-
"boolean",
|
|
293
|
-
"break",
|
|
294
|
-
"byte",
|
|
295
|
-
"case",
|
|
296
|
-
"catch",
|
|
297
|
-
"char",
|
|
298
|
-
"class",
|
|
299
|
-
"const",
|
|
300
|
-
"continue",
|
|
301
|
-
"debugger",
|
|
302
|
-
"default",
|
|
303
|
-
"delete",
|
|
304
|
-
"do",
|
|
305
|
-
"double",
|
|
306
|
-
"else",
|
|
307
|
-
"enum",
|
|
308
|
-
"export",
|
|
309
|
-
"extends",
|
|
310
|
-
"false",
|
|
311
|
-
"final",
|
|
312
|
-
"finally",
|
|
313
|
-
"float",
|
|
314
|
-
"for",
|
|
315
|
-
"function",
|
|
316
|
-
"goto",
|
|
317
|
-
"if",
|
|
318
|
-
"implements",
|
|
319
|
-
"import",
|
|
320
|
-
"in",
|
|
321
|
-
"instanceof",
|
|
322
|
-
"int",
|
|
323
|
-
"interface",
|
|
324
|
-
"let",
|
|
325
|
-
"long",
|
|
326
|
-
"native",
|
|
327
|
-
"new",
|
|
328
|
-
"null",
|
|
329
|
-
"package",
|
|
330
|
-
"private",
|
|
331
|
-
"protected",
|
|
332
|
-
"public",
|
|
333
|
-
"return",
|
|
334
|
-
"short",
|
|
335
|
-
"static",
|
|
336
|
-
"super",
|
|
337
|
-
"switch",
|
|
338
|
-
"synchronized",
|
|
339
|
-
"this",
|
|
340
|
-
"throw",
|
|
341
|
-
"transient",
|
|
342
|
-
"true",
|
|
343
|
-
"try",
|
|
344
|
-
"typeof",
|
|
345
|
-
"var",
|
|
346
|
-
"void",
|
|
347
|
-
"volatile",
|
|
348
|
-
"while",
|
|
349
|
-
"with",
|
|
350
|
-
"yield"
|
|
351
|
-
];
|
|
352
|
-
const regexIdentifierName = /^(?:[$_\p{ID_Start}])(?:[$_\u200C\u200D\p{ID_Continue}])*$/u;
|
|
353
|
-
if (reservedKeywords.includes(name) || !regexIdentifierName.test(name)) {
|
|
354
|
-
return false;
|
|
355
|
-
}
|
|
356
|
-
return true;
|
|
357
|
-
}
|
|
358
311
|
}
|
package/dist/qiankun/master.js
CHANGED
|
@@ -219,16 +219,6 @@ export { MicroAppWithMemoHistory } from './MicroAppWithMemoHistory';
|
|
|
219
219
|
`
|
|
220
220
|
});
|
|
221
221
|
});
|
|
222
|
-
api.chainWebpack((config, { ssr }) => {
|
|
223
|
-
if (ssr) {
|
|
224
|
-
const originalExternals = config.get("externals");
|
|
225
|
-
config.externals({
|
|
226
|
-
...originalExternals,
|
|
227
|
-
qiankun: "fs"
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
return config;
|
|
231
|
-
});
|
|
232
222
|
};
|
|
233
223
|
// Annotate the CommonJS export names for ESM import in node:
|
|
234
224
|
0 && (module.exports = {
|
package/dist/qiankun/slave.js
CHANGED
|
@@ -171,10 +171,7 @@ export interface IRuntimeConfig {
|
|
|
171
171
|
`window.publicPath = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__ || "${api.config.publicPath || "/"}";`
|
|
172
172
|
];
|
|
173
173
|
});
|
|
174
|
-
api.chainWebpack((config
|
|
175
|
-
if (ssr) {
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
174
|
+
api.chainWebpack((config) => {
|
|
178
175
|
(0, import_assert.default)(api.pkg.name, "You should have name in package.json.");
|
|
179
176
|
const {
|
|
180
177
|
shouldNotAddLibraryChunkName = api.env === "production" || !Boolean(api.config.mfsu)
|
|
@@ -204,14 +201,11 @@ export interface IRuntimeConfig {
|
|
|
204
201
|
});
|
|
205
202
|
api.addEntryCode(() => [
|
|
206
203
|
`
|
|
207
|
-
const
|
|
208
|
-
const
|
|
209
|
-
export const
|
|
210
|
-
export const
|
|
211
|
-
|
|
212
|
-
export const update = isServer ? qiankun_noop : qiankun_genUpdate();
|
|
213
|
-
// 增加 ssr 的判断
|
|
214
|
-
if (!isServer && !window.__POWERED_BY_QIANKUN__) {
|
|
204
|
+
export const bootstrap = qiankun_genBootstrap(render);
|
|
205
|
+
export const mount = qiankun_genMount('${api.config.mountElementId}');
|
|
206
|
+
export const unmount = qiankun_genUnmount('${api.config.mountElementId}');
|
|
207
|
+
export const update = qiankun_genUpdate();
|
|
208
|
+
if (!window.__POWERED_BY_QIANKUN__) {
|
|
215
209
|
bootstrap().then(mount);
|
|
216
210
|
}
|
|
217
211
|
`
|
package/dist/react-query.js
CHANGED
|
@@ -24,25 +24,20 @@ __export(react_query_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(react_query_exports);
|
|
25
25
|
var import_utils = require("@umijs/utils");
|
|
26
26
|
var import_path = require("path");
|
|
27
|
+
var import_npmClient = require("./utils/npmClient");
|
|
27
28
|
var import_resolveProjectDep = require("./utils/resolveProjectDep");
|
|
28
29
|
var import_withTmpPath = require("./utils/withTmpPath");
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}).deepPartial();
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
enableBy: api.EnableBy.config
|
|
41
|
-
});
|
|
30
|
+
var reactQueryInfo;
|
|
31
|
+
var REACT_QUERY_DEP_NAME = "@tanstack/react-query";
|
|
32
|
+
var REACT_QUERY_DEVTOOLS_DEP_NAME = "@tanstack/react-query-devtools";
|
|
33
|
+
var REACT_QUERY_CORE_DEP_NAME = "@tanstack/query-core";
|
|
34
|
+
var getReactQueryPkgInfo = (api) => {
|
|
35
|
+
if (reactQueryInfo) {
|
|
36
|
+
return reactQueryInfo;
|
|
37
|
+
}
|
|
42
38
|
let pkgPath;
|
|
43
39
|
let devtoolsPkgPath;
|
|
44
|
-
|
|
45
|
-
const REACT_QUERY_DEVTOOLS_DEP_NAME = "@tanstack/react-query-devtools";
|
|
40
|
+
let corePath;
|
|
46
41
|
const defaultPkgPath = (0, import_utils.winPath)(
|
|
47
42
|
(0, import_path.dirname)(require.resolve(`${REACT_QUERY_DEP_NAME}/package.json`))
|
|
48
43
|
);
|
|
@@ -61,6 +56,16 @@ var react_query_default = (api) => {
|
|
|
61
56
|
`[reactQuery] package '${REACT_QUERY_DEP_NAME}' resolve failed, ${e.message}`
|
|
62
57
|
);
|
|
63
58
|
}
|
|
59
|
+
try {
|
|
60
|
+
corePath = (0, import_utils.winPath)(
|
|
61
|
+
(0, import_path.dirname)(
|
|
62
|
+
require.resolve(`${REACT_QUERY_CORE_DEP_NAME}/package.json`, {
|
|
63
|
+
paths: [pkgPath]
|
|
64
|
+
})
|
|
65
|
+
)
|
|
66
|
+
);
|
|
67
|
+
} catch {
|
|
68
|
+
}
|
|
64
69
|
try {
|
|
65
70
|
const localDevtoolsPkgPath = (0, import_resolveProjectDep.resolveProjectDep)({
|
|
66
71
|
pkg: api.pkg,
|
|
@@ -82,7 +87,35 @@ var react_query_default = (api) => {
|
|
|
82
87
|
const useV5 = pkgVersion.startsWith("5");
|
|
83
88
|
const useV5Devtools = devtoolsVersion.startsWith("5");
|
|
84
89
|
const canUseDevtools = useV4 && useV4Devtools || useV5 && useV5Devtools;
|
|
90
|
+
reactQueryInfo = {
|
|
91
|
+
pkgPath,
|
|
92
|
+
devtoolsPkgPath,
|
|
93
|
+
defaultPkgPath,
|
|
94
|
+
defaultDevtoolPkgPath,
|
|
95
|
+
pkgVersion,
|
|
96
|
+
canUseDevtools,
|
|
97
|
+
useV4,
|
|
98
|
+
useV5,
|
|
99
|
+
corePath
|
|
100
|
+
};
|
|
101
|
+
return reactQueryInfo;
|
|
102
|
+
};
|
|
103
|
+
var react_query_default = (api) => {
|
|
104
|
+
api.describe({
|
|
105
|
+
key: "reactQuery",
|
|
106
|
+
config: {
|
|
107
|
+
schema({ zod }) {
|
|
108
|
+
return zod.object({
|
|
109
|
+
devtool: zod.union([zod.record(zod.any()), zod.boolean()]),
|
|
110
|
+
queryClient: zod.union([zod.record(zod.any()), zod.boolean()])
|
|
111
|
+
}).deepPartial();
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
enableBy: api.EnableBy.config
|
|
115
|
+
});
|
|
85
116
|
api.onStart(() => {
|
|
117
|
+
getReactQueryPkgInfo(api);
|
|
118
|
+
const { pkgPath, defaultPkgPath, pkgVersion } = reactQueryInfo;
|
|
86
119
|
if (pkgPath !== defaultPkgPath && !process.env.IS_UMI_BUILD_WORKER) {
|
|
87
120
|
api.logger.info(`[reactQuery] use local package, version: ${pkgVersion}`);
|
|
88
121
|
}
|
|
@@ -94,6 +127,7 @@ var react_query_default = (api) => {
|
|
|
94
127
|
return ["reactQuery"];
|
|
95
128
|
});
|
|
96
129
|
api.modifyConfig((memo) => {
|
|
130
|
+
const { pkgPath, devtoolsPkgPath, canUseDevtools } = getReactQueryPkgInfo(api);
|
|
97
131
|
memo.alias[REACT_QUERY_DEP_NAME] = pkgPath;
|
|
98
132
|
if (canUseDevtools) {
|
|
99
133
|
memo.alias[REACT_QUERY_DEVTOOLS_DEP_NAME] = devtoolsPkgPath;
|
|
@@ -102,6 +136,7 @@ var react_query_default = (api) => {
|
|
|
102
136
|
});
|
|
103
137
|
api.onGenerateFiles(() => {
|
|
104
138
|
var _a;
|
|
139
|
+
const { pkgPath, devtoolsPkgPath, canUseDevtools, useV4, useV5 } = getReactQueryPkgInfo(api);
|
|
105
140
|
const enableDevTools = api.config.reactQuery.devtool !== false && canUseDevtools;
|
|
106
141
|
const enableQueryClient = api.config.reactQuery.queryClient !== false;
|
|
107
142
|
const reactQueryRuntimeCode = ((_a = api.appData.appJS) == null ? void 0 : _a.exports.includes(
|
|
@@ -134,60 +169,105 @@ export function rootContainer(container) {
|
|
|
134
169
|
</QueryClientProvider>
|
|
135
170
|
);
|
|
136
171
|
}
|
|
137
|
-
` : ""
|
|
172
|
+
` : "export {}"
|
|
138
173
|
});
|
|
174
|
+
const exportMembers = [
|
|
175
|
+
// from @tanstack/query-core
|
|
176
|
+
"QueryClient",
|
|
177
|
+
"QueryCache",
|
|
178
|
+
"MutationCache",
|
|
179
|
+
"QueryObserver",
|
|
180
|
+
"InfiniteQueryObserver",
|
|
181
|
+
"QueriesObserver",
|
|
182
|
+
"MutationObserver",
|
|
183
|
+
// from @tanstack/react-query
|
|
184
|
+
"useQuery",
|
|
185
|
+
"useQueries",
|
|
186
|
+
"useInfiniteQuery",
|
|
187
|
+
"useMutation",
|
|
188
|
+
"useIsFetching",
|
|
189
|
+
"useIsMutating",
|
|
190
|
+
...useV5 ? [
|
|
191
|
+
"useMutationState",
|
|
192
|
+
"useSuspenseQuery",
|
|
193
|
+
"useSuspenseInfiniteQuery",
|
|
194
|
+
"useSuspenseQueries",
|
|
195
|
+
"queryOptions",
|
|
196
|
+
"infiniteQueryOptions"
|
|
197
|
+
] : [],
|
|
198
|
+
"QueryClientProvider",
|
|
199
|
+
"useQueryClient",
|
|
200
|
+
"QueryErrorResetBoundary",
|
|
201
|
+
"useQueryErrorResetBoundary",
|
|
202
|
+
"useIsRestoring",
|
|
203
|
+
"IsRestoringProvider"
|
|
204
|
+
].filter(Boolean);
|
|
139
205
|
api.writeTmpFile({
|
|
140
206
|
path: "index.tsx",
|
|
141
207
|
content: `
|
|
142
208
|
export {
|
|
143
|
-
|
|
144
|
-
QueryClient,
|
|
145
|
-
MutationObserver,
|
|
146
|
-
MutationCache,
|
|
147
|
-
InfiniteQueryObserver,
|
|
148
|
-
QueriesObserver,
|
|
149
|
-
QueryObserver,
|
|
150
|
-
QueryCache,
|
|
151
|
-
// from @tanstack/react-query
|
|
152
|
-
useIsRestoring,
|
|
153
|
-
IsRestoringProvider,
|
|
154
|
-
useInfiniteQuery,
|
|
155
|
-
useIsMutating,
|
|
156
|
-
useIsFetching,
|
|
157
|
-
useMutation,
|
|
158
|
-
useQueries,
|
|
159
|
-
useQuery,
|
|
160
|
-
QueryClientProvider,
|
|
161
|
-
useQueryClient,
|
|
162
|
-
QueryErrorResetBoundary,
|
|
163
|
-
useQueryErrorResetBoundary,
|
|
164
|
-
${useV5 ? "queryOptions," : ""}
|
|
209
|
+
${exportMembers.join(",\n ")}
|
|
165
210
|
} from '${pkgPath}';
|
|
166
211
|
`
|
|
167
212
|
});
|
|
213
|
+
const exportTypes = [
|
|
214
|
+
// from @tanstack/query-core
|
|
215
|
+
"Query",
|
|
216
|
+
"QueryState",
|
|
217
|
+
"Mutation",
|
|
218
|
+
// from @tanstack/react-query
|
|
219
|
+
"QueriesResults",
|
|
220
|
+
"QueriesOptions",
|
|
221
|
+
"QueryErrorResetBoundaryProps",
|
|
222
|
+
"QueryClientProviderProps",
|
|
223
|
+
useV4 && "ContextOptions as QueryContextOptions,",
|
|
224
|
+
"UseQueryOptions",
|
|
225
|
+
"UseBaseQueryOptions",
|
|
226
|
+
"UseQueryResult",
|
|
227
|
+
"UseBaseQueryResult",
|
|
228
|
+
"UseInfiniteQueryOptions",
|
|
229
|
+
"UseMutationResult",
|
|
230
|
+
"UseMutateFunction",
|
|
231
|
+
"UseMutateAsyncFunction",
|
|
232
|
+
"UseBaseMutationResult"
|
|
233
|
+
].filter(Boolean);
|
|
168
234
|
api.writeTmpFile({
|
|
169
235
|
path: "types.d.ts",
|
|
170
236
|
content: `
|
|
171
237
|
export type {
|
|
172
|
-
|
|
173
|
-
Query, QueryState, Mutation,
|
|
174
|
-
// from @tanstack/react-query
|
|
175
|
-
QueriesResults,
|
|
176
|
-
QueriesOptions,
|
|
177
|
-
QueryErrorResetBoundaryProps,
|
|
178
|
-
QueryClientProviderProps,
|
|
179
|
-
${useV4 ? "ContextOptions as QueryContextOptions," : ""}
|
|
180
|
-
UseQueryOptions,
|
|
181
|
-
UseBaseQueryOptions,
|
|
182
|
-
UseQueryResult,
|
|
183
|
-
UseBaseQueryResult,
|
|
184
|
-
UseInfiniteQueryOptions,
|
|
185
|
-
UseMutationResult,
|
|
186
|
-
UseMutateFunction,
|
|
187
|
-
UseMutateAsyncFunction,
|
|
188
|
-
UseBaseMutationResult,
|
|
238
|
+
${exportTypes.join(",\n ")}
|
|
189
239
|
} from '${pkgPath}';
|
|
190
240
|
`
|
|
191
241
|
});
|
|
242
|
+
api.writeTmpFile({
|
|
243
|
+
path: "types.d.ts",
|
|
244
|
+
content: enableQueryClient ? `
|
|
245
|
+
import React from 'react';
|
|
246
|
+
import { QueryClientConfig } from '${pkgPath}';
|
|
247
|
+
${enableDevTools ? `
|
|
248
|
+
import { ReactQueryDevtools } from '${devtoolsPkgPath}';
|
|
249
|
+
` : ""}
|
|
250
|
+
|
|
251
|
+
export type RuntimeReactQueryType = {
|
|
252
|
+
${enableDevTools ? `
|
|
253
|
+
devtool?: React.ComponentProps<typeof ReactQueryDevtools>
|
|
254
|
+
` : ""}
|
|
255
|
+
queryClient?: QueryClientConfig
|
|
256
|
+
}` : "export type RuntimeReactQueryType = {}"
|
|
257
|
+
});
|
|
192
258
|
});
|
|
259
|
+
const isFlattedDepsDir = (0, import_npmClient.isFlattedNodeModulesDir)(api);
|
|
260
|
+
if (!isFlattedDepsDir) {
|
|
261
|
+
api.modifyTSConfig((config) => {
|
|
262
|
+
const { corePath, useV5 } = getReactQueryPkgInfo(api);
|
|
263
|
+
if (useV5 && (corePath == null ? void 0 : corePath.length)) {
|
|
264
|
+
import_utils.lodash.set(
|
|
265
|
+
config,
|
|
266
|
+
`compilerOptions.paths["${REACT_QUERY_CORE_DEP_NAME}"]`,
|
|
267
|
+
[corePath]
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
return config;
|
|
271
|
+
});
|
|
272
|
+
}
|
|
193
273
|
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/utils/npmClient.ts
|
|
20
|
+
var npmClient_exports = {};
|
|
21
|
+
__export(npmClient_exports, {
|
|
22
|
+
isFlattedNodeModulesDir: () => isFlattedNodeModulesDir
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(npmClient_exports);
|
|
25
|
+
var import_plugin_utils = require("umi/plugin-utils");
|
|
26
|
+
var FLATTED_NPM_CLIENT = [
|
|
27
|
+
import_plugin_utils.NpmClientEnum.npm,
|
|
28
|
+
import_plugin_utils.NpmClientEnum.yarn
|
|
29
|
+
];
|
|
30
|
+
var isFlattedNodeModulesDir = (api) => {
|
|
31
|
+
var _a;
|
|
32
|
+
let currentNpmClient = api.appData.npmClient;
|
|
33
|
+
const tnpmCompatMode = api.appData.npmClient === import_plugin_utils.NpmClientEnum.tnpm && ((_a = api.pkg.tnpm) == null ? void 0 : _a.mode);
|
|
34
|
+
if (tnpmCompatMode) {
|
|
35
|
+
if (FLATTED_NPM_CLIENT.includes(api.pkg.tnpm.mode)) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const isFlattedDir = FLATTED_NPM_CLIENT.includes(currentNpmClient);
|
|
40
|
+
return isFlattedDir;
|
|
41
|
+
};
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
isFlattedNodeModulesDir
|
|
45
|
+
});
|
|
@@ -167,6 +167,13 @@ export const MicroApp = forwardRef(
|
|
|
167
167
|
props: { settings: settingsFromConfig = {}, ...propsFromConfig } = {},
|
|
168
168
|
} = appConfig || {};
|
|
169
169
|
|
|
170
|
+
const __globalRoutesInfo = {
|
|
171
|
+
appNameKeyAlias,
|
|
172
|
+
masterHistoryType,
|
|
173
|
+
base: globalSettings.base,
|
|
174
|
+
microAppRoutes: globalSettings.microAppRoutes,
|
|
175
|
+
};
|
|
176
|
+
|
|
170
177
|
useEffect(() => {
|
|
171
178
|
setComponentError(null);
|
|
172
179
|
setLoading(true);
|
|
@@ -185,12 +192,7 @@ export const MicroApp = forwardRef(
|
|
|
185
192
|
...propsFromConfig,
|
|
186
193
|
...stateForSlave,
|
|
187
194
|
...propsFromParams,
|
|
188
|
-
__globalRoutesInfo
|
|
189
|
-
appNameKeyAlias,
|
|
190
|
-
masterHistoryType,
|
|
191
|
-
base: globalSettings.base,
|
|
192
|
-
microAppRoutes: globalSettings.microAppRoutes,
|
|
193
|
-
},
|
|
195
|
+
__globalRoutesInfo,
|
|
194
196
|
setLoading,
|
|
195
197
|
},
|
|
196
198
|
},
|
|
@@ -263,6 +265,7 @@ export const MicroApp = forwardRef(
|
|
|
263
265
|
...propsFromConfig,
|
|
264
266
|
...stateForSlave,
|
|
265
267
|
...propsFromParams,
|
|
268
|
+
__globalRoutesInfo,
|
|
266
269
|
setLoading,
|
|
267
270
|
};
|
|
268
271
|
|
|
@@ -77,10 +77,6 @@ function patchMicroAppRouteComponent(routes: any[]) {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
export async function render(oldRender: typeof noop) {
|
|
80
|
-
// 在 ssr 的场景下,直接返回旧的 render
|
|
81
|
-
if (typeof window === 'undefined') {
|
|
82
|
-
return oldRender();
|
|
83
|
-
}
|
|
84
80
|
const runtimeOptions = await getMasterRuntime();
|
|
85
81
|
let masterOptions: MasterOptions = {
|
|
86
82
|
...getMasterOptions(),
|
|
@@ -142,10 +138,6 @@ export async function render(oldRender: typeof noop) {
|
|
|
142
138
|
}
|
|
143
139
|
|
|
144
140
|
export function patchClientRoutes({ routes }: { routes: any[] }) {
|
|
145
|
-
// 在 ssr 的场景下,不执行主应用的 patchClientRoutes
|
|
146
|
-
if (typeof window === 'undefined') {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
141
|
const microAppRoutes = [].concat(
|
|
150
142
|
deepFilterLeafRoutes(routes),
|
|
151
143
|
deepFilterLeafRoutes(microAppRuntimeRoutes),
|
|
@@ -3,10 +3,6 @@ import { createHistory } from '@@/core/history';
|
|
|
3
3
|
import qiankunRender, { contextOptsStack } from './lifecycles';
|
|
4
4
|
|
|
5
5
|
export function render(oldRender: any) {
|
|
6
|
-
// 在 ssr 的场景下,直接返回旧的 render
|
|
7
|
-
if (typeof window === 'undefined') {
|
|
8
|
-
return oldRender();
|
|
9
|
-
}
|
|
10
6
|
return qiankunRender().then(oldRender);
|
|
11
7
|
}
|
|
12
8
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/plugins",
|
|
3
|
-
"version": "4.0.0-canary.
|
|
3
|
+
"version": "4.0.0-canary.20240624.1",
|
|
4
4
|
"description": "@umijs/plugins",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/plugins#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"@ant-design/icons": "^4.7.0",
|
|
24
24
|
"@ant-design/moment-webpack-plugin": "^0.0.3",
|
|
25
25
|
"@ant-design/pro-components": "^2.0.1",
|
|
26
|
+
"@module-federation/enhanced": "^0.1.13",
|
|
26
27
|
"@tanstack/react-query": "^4.24.10",
|
|
27
28
|
"@tanstack/react-query-devtools": "^4.24.10",
|
|
28
29
|
"antd-dayjs-webpack-plugin": "^1.0.6",
|
|
@@ -45,12 +46,12 @@
|
|
|
45
46
|
"styled-components": "6.1.1",
|
|
46
47
|
"tslib": "^2",
|
|
47
48
|
"warning": "^4.0.3",
|
|
48
|
-
"@umijs/bundler-utils": "4.0.0-canary.
|
|
49
|
+
"@umijs/bundler-utils": "4.0.0-canary.20240624.1",
|
|
49
50
|
"@umijs/valtio": "1.0.4"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
53
|
"antd": "^4.24.1",
|
|
53
|
-
"umi": "4.0.0-canary.
|
|
54
|
+
"umi": "4.0.0-canary.20240624.1"
|
|
54
55
|
},
|
|
55
56
|
"publishConfig": {
|
|
56
57
|
"access": "public"
|