@umijs/plugins 4.0.0-canary.20240509.4 → 4.0.0-canary.20240511.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/qiankun/master.js +0 -10
- package/dist/qiankun/slave.js +6 -12
- package/dist/react-query.js +98 -40
- 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 +3 -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/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,6 +24,7 @@ __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
30
|
var react_query_default = (api) => {
|
|
@@ -134,60 +135,117 @@ export function rootContainer(container) {
|
|
|
134
135
|
</QueryClientProvider>
|
|
135
136
|
);
|
|
136
137
|
}
|
|
137
|
-
` : ""
|
|
138
|
+
` : "export {}"
|
|
138
139
|
});
|
|
140
|
+
const exportMembers = [
|
|
141
|
+
// from @tanstack/query-core
|
|
142
|
+
"QueryClient",
|
|
143
|
+
"QueryCache",
|
|
144
|
+
"MutationCache",
|
|
145
|
+
"QueryObserver",
|
|
146
|
+
"InfiniteQueryObserver",
|
|
147
|
+
"QueriesObserver",
|
|
148
|
+
"MutationObserver",
|
|
149
|
+
// from @tanstack/react-query
|
|
150
|
+
"useQuery",
|
|
151
|
+
"useQueries",
|
|
152
|
+
"useInfiniteQuery",
|
|
153
|
+
"useMutation",
|
|
154
|
+
"useIsFetching",
|
|
155
|
+
"useIsMutating",
|
|
156
|
+
...useV5 ? [
|
|
157
|
+
"useMutationState",
|
|
158
|
+
"useSuspenseQuery",
|
|
159
|
+
"useSuspenseInfiniteQuery",
|
|
160
|
+
"useSuspenseQueries",
|
|
161
|
+
"queryOptions",
|
|
162
|
+
"infiniteQueryOptions"
|
|
163
|
+
] : [],
|
|
164
|
+
"QueryClientProvider",
|
|
165
|
+
"useQueryClient",
|
|
166
|
+
"QueryErrorResetBoundary",
|
|
167
|
+
"useQueryErrorResetBoundary",
|
|
168
|
+
"useIsRestoring",
|
|
169
|
+
"IsRestoringProvider"
|
|
170
|
+
].filter(Boolean);
|
|
139
171
|
api.writeTmpFile({
|
|
140
172
|
path: "index.tsx",
|
|
141
173
|
content: `
|
|
142
174
|
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," : ""}
|
|
175
|
+
${exportMembers.join(",\n ")}
|
|
165
176
|
} from '${pkgPath}';
|
|
166
177
|
`
|
|
167
178
|
});
|
|
179
|
+
const exportTypes = [
|
|
180
|
+
// from @tanstack/query-core
|
|
181
|
+
"Query",
|
|
182
|
+
"QueryState",
|
|
183
|
+
"Mutation",
|
|
184
|
+
// from @tanstack/react-query
|
|
185
|
+
"QueriesResults",
|
|
186
|
+
"QueriesOptions",
|
|
187
|
+
"QueryErrorResetBoundaryProps",
|
|
188
|
+
"QueryClientProviderProps",
|
|
189
|
+
useV4 && "ContextOptions as QueryContextOptions,",
|
|
190
|
+
"UseQueryOptions",
|
|
191
|
+
"UseBaseQueryOptions",
|
|
192
|
+
"UseQueryResult",
|
|
193
|
+
"UseBaseQueryResult",
|
|
194
|
+
"UseInfiniteQueryOptions",
|
|
195
|
+
"UseMutationResult",
|
|
196
|
+
"UseMutateFunction",
|
|
197
|
+
"UseMutateAsyncFunction",
|
|
198
|
+
"UseBaseMutationResult"
|
|
199
|
+
].filter(Boolean);
|
|
168
200
|
api.writeTmpFile({
|
|
169
201
|
path: "types.d.ts",
|
|
170
202
|
content: `
|
|
171
203
|
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,
|
|
204
|
+
${exportTypes.join(",\n ")}
|
|
189
205
|
} from '${pkgPath}';
|
|
190
206
|
`
|
|
191
207
|
});
|
|
208
|
+
api.writeTmpFile({
|
|
209
|
+
path: "types.d.ts",
|
|
210
|
+
content: enableQueryClient ? `
|
|
211
|
+
import React from 'react';
|
|
212
|
+
import { QueryClientConfig } from '${pkgPath}';
|
|
213
|
+
${enableDevTools ? `
|
|
214
|
+
import { ReactQueryDevtools } from '${devtoolsPkgPath}';
|
|
215
|
+
` : ""}
|
|
216
|
+
|
|
217
|
+
export type RuntimeReactQueryType = {
|
|
218
|
+
${enableDevTools ? `
|
|
219
|
+
devtool?: React.ComponentProps<typeof ReactQueryDevtools>
|
|
220
|
+
` : ""}
|
|
221
|
+
queryClient?: QueryClientConfig
|
|
222
|
+
}` : "export type RuntimeReactQueryType = {}"
|
|
223
|
+
});
|
|
192
224
|
});
|
|
225
|
+
const isFlattedDepsDir = (0, import_npmClient.isFlattedNodeModulesDir)(api);
|
|
226
|
+
if (useV5 && !isFlattedDepsDir) {
|
|
227
|
+
let corePath;
|
|
228
|
+
const REACT_QUERY_CORE_DEP_NAME = "@tanstack/query-core";
|
|
229
|
+
try {
|
|
230
|
+
corePath = (0, import_utils.winPath)(
|
|
231
|
+
(0, import_path.dirname)(
|
|
232
|
+
require.resolve(`${REACT_QUERY_CORE_DEP_NAME}/package.json`, {
|
|
233
|
+
paths: [pkgPath]
|
|
234
|
+
})
|
|
235
|
+
)
|
|
236
|
+
);
|
|
237
|
+
} catch (e) {
|
|
238
|
+
throw new Error(
|
|
239
|
+
`[reactQuery] package '${REACT_QUERY_CORE_DEP_NAME}' resolve failed, ${e.message}`
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
api.modifyTSConfig((config) => {
|
|
243
|
+
import_utils.lodash.set(
|
|
244
|
+
config,
|
|
245
|
+
`compilerOptions.paths["${REACT_QUERY_CORE_DEP_NAME}"]`,
|
|
246
|
+
[corePath]
|
|
247
|
+
);
|
|
248
|
+
return config;
|
|
249
|
+
});
|
|
250
|
+
}
|
|
193
251
|
};
|
|
@@ -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.20240511.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",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"styled-components": "6.1.1",
|
|
46
46
|
"tslib": "^2",
|
|
47
47
|
"warning": "^4.0.3",
|
|
48
|
-
"@umijs/bundler-utils": "4.0.0-canary.
|
|
48
|
+
"@umijs/bundler-utils": "4.0.0-canary.20240511.1",
|
|
49
49
|
"@umijs/valtio": "1.0.4"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"antd": "^4.24.1",
|
|
53
|
-
"umi": "4.0.0-canary.
|
|
53
|
+
"umi": "4.0.0-canary.20240511.1"
|
|
54
54
|
},
|
|
55
55
|
"publishConfig": {
|
|
56
56
|
"access": "public"
|