@umijs/plugins 4.0.75 → 4.0.77

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 CHANGED
@@ -54,6 +54,7 @@ var antd_default = (api) => {
54
54
  } catch (e) {
55
55
  }
56
56
  const isV5 = antdVersion.startsWith("5");
57
+ const isV4 = antdVersion.startsWith("4");
57
58
  const appComponentAvailable = import_plugin_utils.semver.gte(antdVersion, "5.1.0");
58
59
  const appConfigAvailable = import_plugin_utils.semver.gte(antdVersion, "5.3.0");
59
60
  const day2MomentAvailable = import_plugin_utils.semver.gte(antdVersion, "5.0.0");
@@ -106,7 +107,7 @@ var antd_default = (api) => {
106
107
  memo.antd = antd = Object.assign(defaultConfig, antd);
107
108
  }
108
109
  memo.alias.antd = pkgPath;
109
- if (antdVersion.startsWith("5")) {
110
+ if (isV5) {
110
111
  const theme = require("@ant-design/antd-theme-variable");
111
112
  memo.theme = {
112
113
  ...theme,
@@ -120,22 +121,21 @@ var antd_default = (api) => {
120
121
  throw Error(errorMessage);
121
122
  }
122
123
  }
123
- if (antd.dark || antd.compact) {
124
- const { getThemeVariables } = require("antd/dist/theme");
124
+ if (isV4) {
125
+ if (antd.dark || antd.compact) {
126
+ const { getThemeVariables } = require("antd/dist/theme");
127
+ memo.theme = {
128
+ ...getThemeVariables(antd),
129
+ ...memo.theme
130
+ };
131
+ }
125
132
  memo.theme = {
126
- ...getThemeVariables(antd),
133
+ "root-entry-name": "default",
127
134
  ...memo.theme
128
135
  };
129
136
  }
130
- memo.theme = {
131
- "root-entry-name": "default",
132
- ...memo.theme
133
- };
134
137
  if (antd.theme) {
135
- (0, import_assert.default)(
136
- antdVersion.startsWith("5"),
137
- `antd.theme is only valid when antd is 5`
138
- );
138
+ (0, import_assert.default)(isV5, `antd.theme is only valid when antd is 5`);
139
139
  antd.configProvider ?? (antd.configProvider = {});
140
140
  antd.configProvider.theme = (0, import_plugin_utils.deepmerge)(
141
141
  antd.configProvider.theme || {},
@@ -169,26 +169,29 @@ var antd_default = (api) => {
169
169
  return memo;
170
170
  });
171
171
  api.addExtraBabelPlugins(() => {
172
- const style = isV5 ? false : api.config.antd.style || "less";
173
- return api.config.antd.import && !api.appData.vite ? [
174
- [
175
- require.resolve("babel-plugin-import"),
176
- {
177
- libraryName: "antd",
178
- libraryDirectory: "es",
179
- ...style ? {
180
- style: style === "less" || "css"
181
- } : {}
182
- },
183
- "antd"
184
- ]
185
- ] : [];
172
+ const style = api.config.antd.style || "less";
173
+ if (api.config.antd.import && !api.appData.vite) {
174
+ return [
175
+ [
176
+ require.resolve("babel-plugin-import"),
177
+ {
178
+ libraryName: "antd",
179
+ libraryDirectory: "es",
180
+ ...isV5 ? {} : { style: style === "less" || "css" }
181
+ },
182
+ "antd"
183
+ ]
184
+ ];
185
+ }
186
+ return [];
186
187
  });
187
188
  api.onGenerateFiles(() => {
188
189
  var _a;
189
190
  const withConfigProvider = !!api.config.antd.configProvider;
190
191
  const withAppConfig = appConfigAvailable && !!api.config.antd.appConfig;
191
192
  const styleProvider = api.config.antd.styleProvider;
193
+ const userInputCompact = api.config.antd.compact;
194
+ const userInputDark = api.config.antd.dark;
192
195
  const ieTarget = !!((_a = api.config.targets) == null ? void 0 : _a.ie) || !!api.config.legacy;
193
196
  let styleProviderConfig = false;
194
197
  if (isV5 && (ieTarget || styleProvider)) {
@@ -216,7 +219,9 @@ var antd_default = (api) => {
216
219
  context: {
217
220
  configProvider: withConfigProvider && JSON.stringify(api.config.antd.configProvider),
218
221
  appConfig: appComponentAvailable && JSON.stringify(api.config.antd.appConfig),
219
- styleProvider: styleProviderConfig
222
+ styleProvider: styleProviderConfig,
223
+ // 是否启用了 v5 的 theme algorithm
224
+ enableV5ThemeAlgorithm: isV5 && (userInputCompact || userInputDark) ? { compact: userInputCompact, dark: userInputDark } : false
220
225
  },
221
226
  tplPath: (0, import_plugin_utils.winPath)((0, import_path.join)(ANTD_TEMPLATES_DIR, "runtime.ts.tpl"))
222
227
  });
@@ -265,10 +270,9 @@ export type IRuntimeConfig = {
265
270
  return [];
266
271
  });
267
272
  api.addEntryImportsAhead(() => {
268
- const isAntd5 = antdVersion.startsWith("5");
269
273
  const style = api.config.antd.style || "less";
270
274
  const imports = [];
271
- if (isAntd5) {
275
+ if (isV5) {
272
276
  imports.push({ source: "antd/dist/reset.css" });
273
277
  } else if (!api.config.antd.import || api.appData.vite) {
274
278
  imports.push({
@@ -173,7 +173,7 @@ export interface IRuntimeConfig {
173
173
  });
174
174
  api.chainWebpack((config) => {
175
175
  (0, import_assert.default)(api.pkg.name, "You should have name in package.json.");
176
- const { shouldNotAddLibraryChunkName } = (api.config.qiankun || {}).slave;
176
+ const { shouldNotAddLibraryChunkName = !Boolean(api.config.mfsu) } = (api.config.qiankun || {}).slave;
177
177
  config.output.libraryTarget("umd").library(
178
178
  shouldNotAddLibraryChunkName ? api.pkg.name : `${api.pkg.name}-[name]`
179
179
  );
@@ -335,5 +335,3 @@ export { MicroAppLink } from './MicroAppLink';
335
335
  };
336
336
  });
337
337
  };
338
- // Annotate the CommonJS export names for ESM import in node:
339
- 0 && (module.exports = {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/plugins",
3
- "version": "4.0.75",
3
+ "version": "4.0.77",
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",
@@ -44,12 +44,12 @@
44
44
  "styled-components": "6.0.0-rc.0",
45
45
  "tslib": "^2",
46
46
  "warning": "^4.0.3",
47
- "@umijs/bundler-utils": "4.0.75",
47
+ "@umijs/bundler-utils": "4.0.77",
48
48
  "@umijs/valtio": "1.0.3"
49
49
  },
50
50
  "devDependencies": {
51
51
  "antd": "^4.24.1",
52
- "umi": "4.0.75"
52
+ "umi": "4.0.77"
53
53
  },
54
54
  "publishConfig": {
55
55
  "access": "public"
@@ -1,14 +1,15 @@
1
1
  import React from 'react';
2
2
  import {
3
3
  Modal,
4
- {{#configProvider}}
5
4
  ConfigProvider,
6
- {{/configProvider}}
7
5
  {{#appConfig}}
8
6
  App,
9
7
  {{/appConfig}}
10
8
  message,
11
9
  notification,
10
+ {{#enableV5ThemeAlgorithm}}
11
+ theme,
12
+ {{/enableV5ThemeAlgorithm}}
12
13
  } from 'antd';
13
14
  import { ApplyPluginsType } from 'umi';
14
15
  {{#styleProvider}}
@@ -47,6 +48,7 @@ export function rootContainer(rawContainer) {
47
48
  ...finalConfigProvider
48
49
  } = getAntdConfig();
49
50
  let container = rawContainer;
51
+
50
52
  {{#configProvider}}
51
53
  if (finalConfigProvider.prefixCls) {
52
54
  Modal.config({
@@ -77,6 +79,26 @@ export function rootContainer(rawContainer) {
77
79
  container = <ConfigProvider {...finalConfigProvider}>{container}</ConfigProvider>;
78
80
  {{/configProvider}}
79
81
 
82
+ {{#enableV5ThemeAlgorithm}}
83
+ // Add token algorithm for antd5 only
84
+ container = (
85
+ <ConfigProvider
86
+ theme={({
87
+ algorithm: [
88
+ {{#enableV5ThemeAlgorithm.compact}}
89
+ theme.compactAlgorithm,
90
+ {{/enableV5ThemeAlgorithm.compact}}
91
+ {{#enableV5ThemeAlgorithm.dark}}
92
+ theme.darkAlgorithm,
93
+ {{/enableV5ThemeAlgorithm.dark}}
94
+ ],
95
+ })}
96
+ >
97
+ {container}
98
+ </ConfigProvider>
99
+ );
100
+ {{/enableV5ThemeAlgorithm}}
101
+
80
102
  {{#styleProvider}}
81
103
  container = (
82
104
  <StyleProvider