@umijs/plugins 4.0.74 → 4.0.76
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 +33 -29
- package/dist/qiankun/master.js +17 -2
- package/libs/qiankun/master/types.ts +1 -0
- package/package.json +4 -4
- package/templates/antd/runtime.ts.tpl +24 -2
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 (
|
|
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 (
|
|
124
|
-
|
|
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
|
-
|
|
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 =
|
|
173
|
-
|
|
174
|
-
[
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
style: style === "less" || "css"
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
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 (
|
|
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({
|
package/dist/qiankun/master.js
CHANGED
|
@@ -33,6 +33,7 @@ __export(master_exports, {
|
|
|
33
33
|
isMasterEnable: () => isMasterEnable
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(master_exports);
|
|
36
|
+
var import_assert = __toESM(require("assert"));
|
|
36
37
|
var import_fs = require("fs");
|
|
37
38
|
var import_path = require("path");
|
|
38
39
|
var import_umi = require("umi");
|
|
@@ -47,6 +48,15 @@ function isMasterEnable(opts) {
|
|
|
47
48
|
}
|
|
48
49
|
return !!process.env.INITIAL_QIANKUN_MASTER_OPTIONS;
|
|
49
50
|
}
|
|
51
|
+
function getCustomLoader(api) {
|
|
52
|
+
var _a, _b, _c;
|
|
53
|
+
const loader = (_b = (_a = api.config.qiankun) == null ? void 0 : _a.master) == null ? void 0 : _b.loader;
|
|
54
|
+
(0, import_assert.default)(
|
|
55
|
+
!loader || ((_c = loader.startsWith) == null ? void 0 : _c.call(loader, "@/")),
|
|
56
|
+
"[@umijs/plugin-qiankun]: loader only support root path, eg: @/loading"
|
|
57
|
+
);
|
|
58
|
+
return loader;
|
|
59
|
+
}
|
|
50
60
|
var master_default = (api) => {
|
|
51
61
|
api.describe({
|
|
52
62
|
key: "qiankun-master",
|
|
@@ -134,8 +144,13 @@ export const setMasterOptions = (newOpts) => options = ({ ...options, ...newOpts
|
|
|
134
144
|
});
|
|
135
145
|
api.writeTmpFile({
|
|
136
146
|
path: "MicroAppLoader.tsx",
|
|
137
|
-
|
|
138
|
-
|
|
147
|
+
content: getCustomLoader(api) ? (
|
|
148
|
+
// 用户自定义的 loading 优先级最高
|
|
149
|
+
`export { default } from '${getCustomLoader(api)}';`
|
|
150
|
+
) : api.isPluginEnable("antd") ? getFileContent("AntdLoader.tsx") : (
|
|
151
|
+
// 开启了 antd 插件的时候,使用 antd 的 loader 组件,否则提示用户必须设置一个自定义的 loader 组件
|
|
152
|
+
`export default function Loader() { console.warn(\`[plugins/qiankun]: Seems like you'r not using @umijs/plugin-antd, you need to provide a custom loader or set autoSetLoading false to shut down this warning!\`); return null; }`
|
|
153
|
+
)
|
|
139
154
|
});
|
|
140
155
|
[
|
|
141
156
|
"common.ts",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/plugins",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.76",
|
|
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/
|
|
48
|
-
"@umijs/
|
|
47
|
+
"@umijs/bundler-utils": "4.0.76",
|
|
48
|
+
"@umijs/valtio": "1.0.3"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"antd": "^4.24.1",
|
|
52
|
-
"umi": "4.0.
|
|
52
|
+
"umi": "4.0.76"
|
|
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
|