@umijs/plugins 4.6.0 → 4.6.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/antd.js +48 -22
- package/package.json +4 -4
- package/templates/antd/runtime.ts.tpl +8 -8
package/dist/antd.js
CHANGED
|
@@ -53,8 +53,13 @@ var antd_default = (api) => {
|
|
|
53
53
|
antdVersion = require(`${pkgPath}/package.json`).version;
|
|
54
54
|
} catch (e) {
|
|
55
55
|
}
|
|
56
|
-
const
|
|
57
|
-
|
|
56
|
+
const isModern = import_plugin_utils.semver.satisfies(
|
|
57
|
+
antdVersion,
|
|
58
|
+
"^5.0.0 || ^6.0.0",
|
|
59
|
+
// 两者都还在维护周期中,允许使用预发布版本. eg. 6.1.0-alpha.0
|
|
60
|
+
{ includePrerelease: true }
|
|
61
|
+
);
|
|
62
|
+
const isLegacy = import_plugin_utils.semver.satisfies(antdVersion, "^4.0.0");
|
|
58
63
|
const appComponentAvailable = import_plugin_utils.semver.gte(antdVersion, "5.1.0");
|
|
59
64
|
const appConfigAvailable = import_plugin_utils.semver.gte(antdVersion, "5.3.0");
|
|
60
65
|
const day2MomentAvailable = import_plugin_utils.semver.gte(antdVersion, "5.0.0");
|
|
@@ -78,7 +83,7 @@ var antd_default = (api) => {
|
|
|
78
83
|
})
|
|
79
84
|
]);
|
|
80
85
|
};
|
|
81
|
-
const
|
|
86
|
+
const createModernSchema = () => {
|
|
82
87
|
const componentNameSchema = zod.string().refine(
|
|
83
88
|
(value) => {
|
|
84
89
|
const firstLetter = value.slice(0, 1);
|
|
@@ -103,17 +108,17 @@ var antd_default = (api) => {
|
|
|
103
108
|
configProvider
|
|
104
109
|
}).deepPartial();
|
|
105
110
|
};
|
|
106
|
-
const
|
|
111
|
+
const createLegacySchema = () => {
|
|
107
112
|
return zod.object({
|
|
108
113
|
...commonSchema,
|
|
109
114
|
configProvider: zod.record(zod.any())
|
|
110
115
|
}).deepPartial();
|
|
111
116
|
};
|
|
112
|
-
if (
|
|
113
|
-
return
|
|
117
|
+
if (isModern) {
|
|
118
|
+
return createModernSchema();
|
|
114
119
|
}
|
|
115
|
-
if (
|
|
116
|
-
return
|
|
120
|
+
if (isLegacy) {
|
|
121
|
+
return createLegacySchema();
|
|
117
122
|
}
|
|
118
123
|
return zod.object({});
|
|
119
124
|
}
|
|
@@ -128,6 +133,16 @@ var antd_default = (api) => {
|
|
|
128
133
|
throw new Error(`Can't find antd package. Please install antd first.`);
|
|
129
134
|
}
|
|
130
135
|
}
|
|
136
|
+
api.onCheck(() => {
|
|
137
|
+
if (import_plugin_utils.semver.gte(antdVersion, "6.0.0")) {
|
|
138
|
+
const reactVersion = api.appData.react.version;
|
|
139
|
+
if (import_plugin_utils.semver.lt(reactVersion, "18.0.0")) {
|
|
140
|
+
throw new Error(
|
|
141
|
+
`antd@6 requires React version >= 18.0.0, but got ${reactVersion}.`
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
});
|
|
131
146
|
api.modifyAppData((memo) => {
|
|
132
147
|
checkPkgPath();
|
|
133
148
|
const version = require(`${pkgPath}/package.json`).version;
|
|
@@ -146,21 +161,23 @@ var antd_default = (api) => {
|
|
|
146
161
|
memo.antd = antd = Object.assign(defaultConfig, antd);
|
|
147
162
|
}
|
|
148
163
|
memo.alias.antd = pkgPath;
|
|
149
|
-
if (
|
|
164
|
+
if (isModern) {
|
|
150
165
|
const theme = require("@ant-design/antd-theme-variable");
|
|
151
166
|
memo.theme = {
|
|
152
167
|
...theme,
|
|
153
168
|
...memo.theme
|
|
154
169
|
};
|
|
170
|
+
}
|
|
171
|
+
if (import_plugin_utils.semver.gte(antdVersion, "5.0.0")) {
|
|
155
172
|
if ((_a = memo.antd) == null ? void 0 : _a.import) {
|
|
156
|
-
const errorMessage = `
|
|
173
|
+
const errorMessage = `The antd.import option is not supported in antd version 5 and above (${antdVersion}).`;
|
|
157
174
|
api.logger.fatal(
|
|
158
175
|
"please change config antd.import to false, then start server again"
|
|
159
176
|
);
|
|
160
177
|
throw Error(errorMessage);
|
|
161
178
|
}
|
|
162
179
|
}
|
|
163
|
-
if (
|
|
180
|
+
if (isLegacy) {
|
|
164
181
|
if (antd.dark || antd.compact) {
|
|
165
182
|
const { getThemeVariables } = require("antd/dist/theme");
|
|
166
183
|
memo.theme = {
|
|
@@ -174,7 +191,10 @@ var antd_default = (api) => {
|
|
|
174
191
|
};
|
|
175
192
|
}
|
|
176
193
|
if (antd.theme) {
|
|
177
|
-
(0, import_assert.default)(
|
|
194
|
+
(0, import_assert.default)(
|
|
195
|
+
isModern,
|
|
196
|
+
`The 'antd.theme' option is only available for antd version 5 and above.`
|
|
197
|
+
);
|
|
178
198
|
antd.configProvider ?? (antd.configProvider = {});
|
|
179
199
|
antd.configProvider.theme = (0, import_plugin_utils.deepmerge)(
|
|
180
200
|
antd.configProvider.theme || {},
|
|
@@ -223,7 +243,7 @@ var antd_default = (api) => {
|
|
|
223
243
|
{
|
|
224
244
|
libraryName: "antd",
|
|
225
245
|
libraryDirectory: "es",
|
|
226
|
-
|
|
246
|
+
style: style === "less" || "css"
|
|
227
247
|
},
|
|
228
248
|
"antd"
|
|
229
249
|
]
|
|
@@ -244,7 +264,7 @@ var antd_default = (api) => {
|
|
|
244
264
|
const userInputDark = api.config.antd.dark;
|
|
245
265
|
const ieTarget = !!((_a = api.config.targets) == null ? void 0 : _a.ie) || !!api.config.legacy;
|
|
246
266
|
let styleProviderConfig = false;
|
|
247
|
-
if (
|
|
267
|
+
if (isModern && (ieTarget || styleProvider)) {
|
|
248
268
|
const cssinjs = (0, import_resolveProjectDep.resolveProjectDep)({
|
|
249
269
|
pkg: api.pkg,
|
|
250
270
|
cwd: api.cwd,
|
|
@@ -255,8 +275,14 @@ var antd_default = (api) => {
|
|
|
255
275
|
cssinjs: (0, import_plugin_utils.winPath)(cssinjs)
|
|
256
276
|
};
|
|
257
277
|
if (ieTarget) {
|
|
258
|
-
|
|
259
|
-
|
|
278
|
+
if (import_plugin_utils.semver.gte(antdVersion, "6.0.0")) {
|
|
279
|
+
api.logger.warn(
|
|
280
|
+
`You are using antd version ${antdVersion} which no longer supports IE, but your targets or legacy config indicates IE support. Please adjust your targets or legacy config accordingly.`
|
|
281
|
+
);
|
|
282
|
+
} else {
|
|
283
|
+
styleProviderConfig.hashPriority = "high";
|
|
284
|
+
styleProviderConfig.legacyTransformer = true;
|
|
285
|
+
}
|
|
260
286
|
}
|
|
261
287
|
styleProviderConfig = {
|
|
262
288
|
...styleProviderConfig,
|
|
@@ -266,9 +292,9 @@ var antd_default = (api) => {
|
|
|
266
292
|
}
|
|
267
293
|
const configProvider = withConfigProvider && JSON.stringify(api.config.antd.configProvider);
|
|
268
294
|
const appConfig = appComponentAvailable && JSON.stringify(api.config.antd.appConfig);
|
|
269
|
-
const
|
|
270
|
-
const hasConfigProvider = configProvider ||
|
|
271
|
-
const antdConfigSetter =
|
|
295
|
+
const enableModernThemeAlgorithm = isModern && (userInputCompact || userInputDark) ? { compact: userInputCompact, dark: userInputDark } : false;
|
|
296
|
+
const hasConfigProvider = configProvider || enableModernThemeAlgorithm;
|
|
297
|
+
const antdConfigSetter = isModern && hasConfigProvider;
|
|
272
298
|
const isModelPluginEnabled = api.isPluginEnable("model");
|
|
273
299
|
const modelPluginCompat = isModelPluginEnabled && antdConfigSetter;
|
|
274
300
|
api.writeTmpFile({
|
|
@@ -277,8 +303,8 @@ var antd_default = (api) => {
|
|
|
277
303
|
configProvider,
|
|
278
304
|
appConfig,
|
|
279
305
|
styleProvider: styleProviderConfig,
|
|
280
|
-
// 是否启用了
|
|
281
|
-
|
|
306
|
+
// 是否启用了 theme algorithm
|
|
307
|
+
enableModernThemeAlgorithm,
|
|
282
308
|
antdConfigSetter,
|
|
283
309
|
modelPluginCompat,
|
|
284
310
|
lodashPath,
|
|
@@ -347,7 +373,7 @@ export const AntdConfigContextSetter = React.createContext<React.Dispatch<React.
|
|
|
347
373
|
api.addEntryImportsAhead(() => {
|
|
348
374
|
const style = api.config.antd.style || "less";
|
|
349
375
|
const imports = [];
|
|
350
|
-
if (
|
|
376
|
+
if (isModern) {
|
|
351
377
|
imports.push({ source: "antd/dist/reset.css" });
|
|
352
378
|
} else if (!api.config.antd.import || api.appData.vite) {
|
|
353
379
|
imports.push({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/plugins",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.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/
|
|
49
|
-
"@umijs/
|
|
48
|
+
"@umijs/valtio": "1.0.4",
|
|
49
|
+
"@umijs/bundler-utils": "4.6.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"antd": "^4.24.1",
|
|
53
|
-
"umi": "4.6.
|
|
53
|
+
"umi": "4.6.1"
|
|
54
54
|
},
|
|
55
55
|
"publishConfig": {
|
|
56
56
|
"access": "public"
|
|
@@ -9,9 +9,9 @@ import {
|
|
|
9
9
|
message,
|
|
10
10
|
notification,
|
|
11
11
|
{{/disableInternalStatic}}
|
|
12
|
-
{{#
|
|
12
|
+
{{#enableModernThemeAlgorithm}}
|
|
13
13
|
theme,
|
|
14
|
-
{{/
|
|
14
|
+
{{/enableModernThemeAlgorithm}}
|
|
15
15
|
} from 'antd';
|
|
16
16
|
import { ApplyPluginsType } from 'umi';
|
|
17
17
|
{{#styleProvider}}
|
|
@@ -61,24 +61,24 @@ function AntdProvider({ children }) {
|
|
|
61
61
|
appConfig: _,
|
|
62
62
|
...finalConfigProvider
|
|
63
63
|
} = getAntdConfig();
|
|
64
|
-
{{#
|
|
64
|
+
{{#enableModernThemeAlgorithm}}
|
|
65
65
|
finalConfigProvider.theme ??= {};
|
|
66
66
|
finalConfigProvider.theme.algorithm ??= [];
|
|
67
67
|
if (!Array.isArray(finalConfigProvider.theme.algorithm)) {
|
|
68
68
|
finalConfigProvider.theme.algorithm = [finalConfigProvider.theme.algorithm];
|
|
69
69
|
}
|
|
70
70
|
const algorithm = finalConfigProvider.theme.algorithm;
|
|
71
|
-
{{#
|
|
71
|
+
{{#enableModernThemeAlgorithm.compact}}
|
|
72
72
|
if (!algorithm.includes(theme.compactAlgorithm)) {
|
|
73
73
|
algorithm.push(theme.compactAlgorithm);
|
|
74
74
|
}
|
|
75
|
-
{{/
|
|
76
|
-
{{#
|
|
75
|
+
{{/enableModernThemeAlgorithm.compact}}
|
|
76
|
+
{{#enableModernThemeAlgorithm.dark}}
|
|
77
77
|
if (!algorithm.includes(theme.darkAlgorithm)) {
|
|
78
78
|
algorithm.push(theme.darkAlgorithm);
|
|
79
79
|
}
|
|
80
|
-
{{/
|
|
81
|
-
{{/
|
|
80
|
+
{{/enableModernThemeAlgorithm.dark}}
|
|
81
|
+
{{/enableModernThemeAlgorithm}}
|
|
82
82
|
return finalConfigProvider
|
|
83
83
|
});
|
|
84
84
|
const setAntdConfig: typeof _setAntdConfig = (newConfig) => {
|