@umijs/plugins 4.1.8 → 4.1.9
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 +98 -40
- package/dist/utils/npmClient.d.ts +2 -0
- package/dist/utils/npmClient.js +45 -0
- 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,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
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/plugins",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.9",
|
|
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.1.
|
|
48
|
+
"@umijs/bundler-utils": "4.1.9",
|
|
49
49
|
"@umijs/valtio": "1.0.4"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"antd": "^4.24.1",
|
|
53
|
-
"umi": "4.1.
|
|
53
|
+
"umi": "4.1.9"
|
|
54
54
|
},
|
|
55
55
|
"publishConfig": {
|
|
56
56
|
"access": "public"
|