@umijs/plugins 4.2.6-alpha.1 → 4.2.6-alpha.5
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/layout.js +2 -8
- 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/package.json +3 -3
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/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
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/plugins",
|
|
3
|
-
"version": "4.2.6-alpha.
|
|
3
|
+
"version": "4.2.6-alpha.5",
|
|
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.2.6-alpha.
|
|
48
|
+
"@umijs/bundler-utils": "4.2.6-alpha.5",
|
|
49
49
|
"@umijs/valtio": "1.0.4"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"antd": "^4.24.1",
|
|
53
|
-
"umi": "4.2.6-alpha.
|
|
53
|
+
"umi": "4.2.6-alpha.5"
|
|
54
54
|
},
|
|
55
55
|
"publishConfig": {
|
|
56
56
|
"access": "public"
|