@umijs/plugins 4.2.3 → 4.2.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/react-query.js +58 -36
- package/package.json +4 -4
package/dist/react-query.js
CHANGED
|
@@ -27,23 +27,17 @@ var import_path = require("path");
|
|
|
27
27
|
var import_npmClient = require("./utils/npmClient");
|
|
28
28
|
var import_resolveProjectDep = require("./utils/resolveProjectDep");
|
|
29
29
|
var import_withTmpPath = require("./utils/withTmpPath");
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}).deepPartial();
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
enableBy: api.EnableBy.config
|
|
42
|
-
});
|
|
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
|
+
}
|
|
43
38
|
let pkgPath;
|
|
44
39
|
let devtoolsPkgPath;
|
|
45
|
-
|
|
46
|
-
const REACT_QUERY_DEVTOOLS_DEP_NAME = "@tanstack/react-query-devtools";
|
|
40
|
+
let corePath;
|
|
47
41
|
const defaultPkgPath = (0, import_utils.winPath)(
|
|
48
42
|
(0, import_path.dirname)(require.resolve(`${REACT_QUERY_DEP_NAME}/package.json`))
|
|
49
43
|
);
|
|
@@ -62,6 +56,16 @@ var react_query_default = (api) => {
|
|
|
62
56
|
`[reactQuery] package '${REACT_QUERY_DEP_NAME}' resolve failed, ${e.message}`
|
|
63
57
|
);
|
|
64
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
|
+
}
|
|
65
69
|
try {
|
|
66
70
|
const localDevtoolsPkgPath = (0, import_resolveProjectDep.resolveProjectDep)({
|
|
67
71
|
pkg: api.pkg,
|
|
@@ -83,7 +87,35 @@ var react_query_default = (api) => {
|
|
|
83
87
|
const useV5 = pkgVersion.startsWith("5");
|
|
84
88
|
const useV5Devtools = devtoolsVersion.startsWith("5");
|
|
85
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
|
+
});
|
|
86
116
|
api.onStart(() => {
|
|
117
|
+
getReactQueryPkgInfo(api);
|
|
118
|
+
const { pkgPath, defaultPkgPath, pkgVersion } = reactQueryInfo;
|
|
87
119
|
if (pkgPath !== defaultPkgPath && !process.env.IS_UMI_BUILD_WORKER) {
|
|
88
120
|
api.logger.info(`[reactQuery] use local package, version: ${pkgVersion}`);
|
|
89
121
|
}
|
|
@@ -95,6 +127,7 @@ var react_query_default = (api) => {
|
|
|
95
127
|
return ["reactQuery"];
|
|
96
128
|
});
|
|
97
129
|
api.modifyConfig((memo) => {
|
|
130
|
+
const { pkgPath, devtoolsPkgPath, canUseDevtools } = getReactQueryPkgInfo(api);
|
|
98
131
|
memo.alias[REACT_QUERY_DEP_NAME] = pkgPath;
|
|
99
132
|
if (canUseDevtools) {
|
|
100
133
|
memo.alias[REACT_QUERY_DEVTOOLS_DEP_NAME] = devtoolsPkgPath;
|
|
@@ -103,6 +136,7 @@ var react_query_default = (api) => {
|
|
|
103
136
|
});
|
|
104
137
|
api.onGenerateFiles(() => {
|
|
105
138
|
var _a;
|
|
139
|
+
const { pkgPath, devtoolsPkgPath, canUseDevtools, useV4, useV5 } = getReactQueryPkgInfo(api);
|
|
106
140
|
const enableDevTools = api.config.reactQuery.devtool !== false && canUseDevtools;
|
|
107
141
|
const enableQueryClient = api.config.reactQuery.queryClient !== false;
|
|
108
142
|
const reactQueryRuntimeCode = ((_a = api.appData.appJS) == null ? void 0 : _a.exports.includes(
|
|
@@ -223,28 +257,16 @@ export type RuntimeReactQueryType = {
|
|
|
223
257
|
});
|
|
224
258
|
});
|
|
225
259
|
const isFlattedDepsDir = (0, import_npmClient.isFlattedNodeModulesDir)(api);
|
|
226
|
-
if (
|
|
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
|
-
}
|
|
260
|
+
if (!isFlattedDepsDir) {
|
|
242
261
|
api.modifyTSConfig((config) => {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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
|
+
}
|
|
248
270
|
return config;
|
|
249
271
|
});
|
|
250
272
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/plugins",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.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/
|
|
49
|
-
"@umijs/
|
|
48
|
+
"@umijs/bundler-utils": "4.2.5",
|
|
49
|
+
"@umijs/valtio": "1.0.4"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"antd": "^4.24.1",
|
|
53
|
-
"umi": "4.2.
|
|
53
|
+
"umi": "4.2.5"
|
|
54
54
|
},
|
|
55
55
|
"publishConfig": {
|
|
56
56
|
"access": "public"
|