@umijs/plugins 4.0.42 → 4.0.43
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/access.js +12 -4
- package/dist/analytics.js +17 -11
- package/dist/antd.js +33 -16
- package/dist/dva.js +15 -7
- package/dist/initial-state.js +6 -3
- package/dist/layout.js +20 -12
- package/dist/locale.js +57 -26
- package/dist/mf.js +40 -16
- package/dist/model.js +14 -5
- package/dist/moment2dayjs.js +14 -6
- package/dist/qiankun/master.js +24 -5
- package/dist/qiankun/slave.js +101 -62
- package/dist/qiankun.js +12 -6
- package/dist/{icons.d.ts → react-query.d.ts} +0 -0
- package/dist/react-query.js +153 -0
- package/dist/request.js +17 -9
- package/dist/styled-components.js +4 -1
- package/dist/tailwindcss.js +24 -14
- package/dist/unocss.js +13 -5
- package/dist/utils/astUtils.js +4 -1
- package/dist/utils/localeUtils.js +11 -5
- package/dist/utils/modelUtils.js +34 -12
- package/dist/utils/resolveProjectDep.js +5 -3
- package/dist/utils/withTmpPath.js +7 -1
- package/dist/valtio.js +7 -2
- package/libs/qiankun/master/MicroApp.tsx +12 -0
- package/libs/qiankun/master/masterRuntimePlugin.tsx +10 -0
- package/libs/qiankun/master/routeUtils.ts +26 -0
- package/libs/qiankun/slave/MicroAppLink.tsx +122 -0
- package/libs/qiankun/slave/constants.ts +5 -0
- package/package.json +12 -9
- package/dist/icons.js +0 -29
package/dist/access.js
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/access.ts
|
|
@@ -32,13 +35,18 @@ var access_default = (api) => {
|
|
|
32
35
|
api.describe({
|
|
33
36
|
config: {
|
|
34
37
|
schema(Joi) {
|
|
35
|
-
return Joi.alternatives().try(
|
|
38
|
+
return Joi.alternatives().try(
|
|
39
|
+
Joi.object(),
|
|
40
|
+
Joi.boolean().invalid(true)
|
|
41
|
+
);
|
|
36
42
|
}
|
|
37
43
|
},
|
|
38
44
|
enableBy: api.EnableBy.config
|
|
39
45
|
});
|
|
40
46
|
api.onGenerateFiles(async () => {
|
|
41
|
-
const hasAccessFile = ["js", "jsx", "ts", "tsx"].some(
|
|
47
|
+
const hasAccessFile = ["js", "jsx", "ts", "tsx"].some(
|
|
48
|
+
(ext) => import_fs.default.existsSync((0, import_path.join)(api.paths.absSrcPath, `access.${ext}`))
|
|
49
|
+
);
|
|
42
50
|
api.writeTmpFile({
|
|
43
51
|
path: "runtime.tsx",
|
|
44
52
|
content: `
|
|
@@ -94,7 +102,7 @@ export const useAccessMarkedRoutes = (routes: IRoute[]) => {
|
|
|
94
102
|
const markdedRoutes: IRoute[] = React.useMemo(() => {
|
|
95
103
|
const process = (route, parentAccessCode, parentRoute) => {
|
|
96
104
|
let accessCode = route.access;
|
|
97
|
-
//
|
|
105
|
+
// 用父级的路由检测父级的 accessCode
|
|
98
106
|
let detectorRoute = route;
|
|
99
107
|
if (!accessCode && parentAccessCode) {
|
|
100
108
|
accessCode = parentAccessCode;
|
package/dist/analytics.js
CHANGED
|
@@ -32,11 +32,14 @@ var analytics_default = (api) => {
|
|
|
32
32
|
key: "analytics",
|
|
33
33
|
config: {
|
|
34
34
|
schema(Joi) {
|
|
35
|
-
return Joi.alternatives().try(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
return Joi.alternatives().try(
|
|
36
|
+
Joi.object({
|
|
37
|
+
baidu: Joi.string(),
|
|
38
|
+
ga: Joi.string(),
|
|
39
|
+
ga_v2: Joi.string()
|
|
40
|
+
}),
|
|
41
|
+
Joi.boolean().invalid(true)
|
|
42
|
+
);
|
|
40
43
|
},
|
|
41
44
|
onChange: api.ConfigChangeType.reload
|
|
42
45
|
},
|
|
@@ -102,12 +105,15 @@ var analytics_default = (api) => {
|
|
|
102
105
|
});
|
|
103
106
|
}
|
|
104
107
|
if (ga_v2) {
|
|
105
|
-
scripts.push(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
scripts.push(
|
|
109
|
+
{
|
|
110
|
+
async: true,
|
|
111
|
+
src: `//www.googletagmanager.com/gtag/js?id=${ga_v2}`
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
content: gaV2Tpl(ga_v2)
|
|
115
|
+
}
|
|
116
|
+
);
|
|
111
117
|
}
|
|
112
118
|
}
|
|
113
119
|
return scripts.filter(Boolean);
|
package/dist/antd.js
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/antd.ts
|
|
@@ -46,14 +49,17 @@ var antd_default = (api) => {
|
|
|
46
49
|
api.describe({
|
|
47
50
|
config: {
|
|
48
51
|
schema(Joi) {
|
|
49
|
-
return Joi.alternatives().try(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
return Joi.alternatives().try(
|
|
53
|
+
Joi.object({
|
|
54
|
+
configProvider: Joi.object(),
|
|
55
|
+
dark: Joi.boolean(),
|
|
56
|
+
compact: Joi.boolean(),
|
|
57
|
+
import: Joi.boolean(),
|
|
58
|
+
style: Joi.string().allow("less", "css"),
|
|
59
|
+
theme: Joi.object()
|
|
60
|
+
}),
|
|
61
|
+
Joi.boolean().invalid(true)
|
|
62
|
+
);
|
|
57
63
|
}
|
|
58
64
|
},
|
|
59
65
|
enableBy({ userConfig }) {
|
|
@@ -95,7 +101,9 @@ var antd_default = (api) => {
|
|
|
95
101
|
};
|
|
96
102
|
if ((_a = memo.antd) == null ? void 0 : _a.style) {
|
|
97
103
|
const errorMessage = `Can't set antd.style while using antd5 (${antdVersion})`;
|
|
98
|
-
api.logger.fatal(
|
|
104
|
+
api.logger.fatal(
|
|
105
|
+
"please remove config antd.style, then start server again"
|
|
106
|
+
);
|
|
99
107
|
throw Error(errorMessage);
|
|
100
108
|
}
|
|
101
109
|
}
|
|
@@ -111,9 +119,15 @@ var antd_default = (api) => {
|
|
|
111
119
|
...memo.theme
|
|
112
120
|
};
|
|
113
121
|
if (antd.theme) {
|
|
114
|
-
(0, import_assert.default)(
|
|
122
|
+
(0, import_assert.default)(
|
|
123
|
+
antdVersion.startsWith("5"),
|
|
124
|
+
`antd.theme is only valid when antd is 5`
|
|
125
|
+
);
|
|
115
126
|
antd.configProvider ?? (antd.configProvider = {});
|
|
116
|
-
antd.configProvider.theme = (0, import_plugin_utils.deepmerge)(
|
|
127
|
+
antd.configProvider.theme = (0, import_plugin_utils.deepmerge)(
|
|
128
|
+
antd.configProvider.theme || {},
|
|
129
|
+
antd.theme
|
|
130
|
+
);
|
|
117
131
|
}
|
|
118
132
|
return memo;
|
|
119
133
|
});
|
|
@@ -138,7 +152,8 @@ var antd_default = (api) => {
|
|
|
138
152
|
return;
|
|
139
153
|
api.writeTmpFile({
|
|
140
154
|
path: `runtime.tsx`,
|
|
141
|
-
content: import_plugin_utils.Mustache.render(
|
|
155
|
+
content: import_plugin_utils.Mustache.render(
|
|
156
|
+
`
|
|
142
157
|
import React from 'react';
|
|
143
158
|
import { ConfigProvider, Modal, message, notification } from 'antd';
|
|
144
159
|
import { ApplyPluginsType } from 'umi';
|
|
@@ -169,9 +184,11 @@ export function rootContainer(container) {
|
|
|
169
184
|
}
|
|
170
185
|
return <ConfigProvider {...finalConfig}>{container}</ConfigProvider>;
|
|
171
186
|
}
|
|
172
|
-
`.trim(),
|
|
173
|
-
|
|
174
|
-
|
|
187
|
+
`.trim(),
|
|
188
|
+
{
|
|
189
|
+
config: JSON.stringify(api.config.antd.configProvider)
|
|
190
|
+
}
|
|
191
|
+
)
|
|
175
192
|
});
|
|
176
193
|
api.writeTmpFile({
|
|
177
194
|
path: "types.d.ts",
|
package/dist/dva.js
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/dva.ts
|
|
@@ -39,11 +42,14 @@ var dva_default = (api) => {
|
|
|
39
42
|
api.describe({
|
|
40
43
|
config: {
|
|
41
44
|
schema(Joi) {
|
|
42
|
-
return Joi.alternatives().try(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
return Joi.alternatives().try(
|
|
46
|
+
Joi.object({
|
|
47
|
+
extraModels: Joi.array().items(Joi.string()),
|
|
48
|
+
immer: Joi.object(),
|
|
49
|
+
skipModelValidate: Joi.boolean()
|
|
50
|
+
}),
|
|
51
|
+
Joi.boolean().invalid(true)
|
|
52
|
+
);
|
|
47
53
|
}
|
|
48
54
|
},
|
|
49
55
|
enableBy: api.EnableBy.config
|
|
@@ -97,7 +103,9 @@ export interface IRuntimeConfig {
|
|
|
97
103
|
import { create, Provider } from 'dva';
|
|
98
104
|
import createLoading from '${(0, import_utils.winPath)(require.resolve("dva-loading"))}';
|
|
99
105
|
${((_a = api.config.dva) == null ? void 0 : _a.immer) ? `
|
|
100
|
-
import dvaImmer, { enableES5, enableAllPlugins } from '${(0, import_utils.winPath)(
|
|
106
|
+
import dvaImmer, { enableES5, enableAllPlugins } from '${(0, import_utils.winPath)(
|
|
107
|
+
require.resolve("dva-immer")
|
|
108
|
+
)}';
|
|
101
109
|
` : ""}
|
|
102
110
|
import React, { useRef } from 'react';
|
|
103
111
|
import { history, ApplyPluginsType, useAppData } from 'umi';
|
package/dist/initial-state.js
CHANGED
|
@@ -28,9 +28,12 @@ var initial_state_default = (api) => {
|
|
|
28
28
|
api.describe({
|
|
29
29
|
config: {
|
|
30
30
|
schema(Joi) {
|
|
31
|
-
return Joi.alternatives().try(
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
return Joi.alternatives().try(
|
|
32
|
+
Joi.object({
|
|
33
|
+
loading: Joi.string()
|
|
34
|
+
}),
|
|
35
|
+
Joi.boolean().invalid(true)
|
|
36
|
+
);
|
|
34
37
|
}
|
|
35
38
|
},
|
|
36
39
|
enableBy: api.EnableBy.config
|
package/dist/layout.js
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/layout.ts
|
|
@@ -47,7 +50,10 @@ var layout_default = (api) => {
|
|
|
47
50
|
key: "layout",
|
|
48
51
|
config: {
|
|
49
52
|
schema(Joi) {
|
|
50
|
-
return Joi.alternatives().try(
|
|
53
|
+
return Joi.alternatives().try(
|
|
54
|
+
Joi.object(),
|
|
55
|
+
Joi.boolean().invalid(true)
|
|
56
|
+
);
|
|
51
57
|
},
|
|
52
58
|
onChange: api.ConfigChangeType.regenerateTmpFiles
|
|
53
59
|
},
|
|
@@ -117,7 +123,7 @@ ${api.config.locale ? `
|
|
|
117
123
|
import { useIntl } from '@@/plugin-locale';
|
|
118
124
|
`.trim() : ""}
|
|
119
125
|
|
|
120
|
-
//
|
|
126
|
+
// 过滤出需要显示的路由, 这里的filterFn 指 不希望显示的层级
|
|
121
127
|
const filterRoutes = (routes: IRoute[], filterFn: (route: IRoute) => boolean) => {
|
|
122
128
|
if (routes.length === 0) {
|
|
123
129
|
return []
|
|
@@ -142,13 +148,13 @@ const filterRoutes = (routes: IRoute[], filterFn: (route: IRoute) => boolean) =>
|
|
|
142
148
|
return newRoutes;
|
|
143
149
|
}
|
|
144
150
|
|
|
145
|
-
//
|
|
151
|
+
// 格式化路由 处理因 wrapper 导致的 菜单 path 不一致
|
|
146
152
|
const mapRoutes = (routes: IRoute[]) => {
|
|
147
153
|
if (routes.length === 0) {
|
|
148
154
|
return []
|
|
149
155
|
}
|
|
150
156
|
return routes.map(route => {
|
|
151
|
-
//
|
|
157
|
+
// 需要 copy 一份, 否则会污染原始数据
|
|
152
158
|
const newRoute = {...route}
|
|
153
159
|
if (route.originPath) {
|
|
154
160
|
newRoute.path = route.originPath
|
|
@@ -189,7 +195,7 @@ const { formatMessage } = useIntl();
|
|
|
189
195
|
});
|
|
190
196
|
|
|
191
197
|
|
|
192
|
-
//
|
|
198
|
+
// 现在的 layout 及 wrapper 实现是通过父路由的形式实现的, 会导致路由数据多了冗余层级, proLayout 消费时, 无法正确展示菜单, 这里对冗余数据进行过滤操作
|
|
193
199
|
const newRoutes = filterRoutes(clientRoutes.filter(route => route.id === 'ant-design-pro-layout'), (route) => {
|
|
194
200
|
return (!!route.isLayout && route.id !== 'ant-design-pro-layout') || !!route.isWrapper;
|
|
195
201
|
})
|
|
@@ -336,7 +342,9 @@ export interface IRuntimeConfig {
|
|
|
336
342
|
return memo;
|
|
337
343
|
}, {});
|
|
338
344
|
const icons = Object.keys(iconsMap);
|
|
339
|
-
const antIconsPath = (0, import_plugin_utils.winPath)(
|
|
345
|
+
const antIconsPath = (0, import_plugin_utils.winPath)(
|
|
346
|
+
(0, import_path.dirname)(require.resolve("@ant-design/icons/package"))
|
|
347
|
+
);
|
|
340
348
|
api.writeTmpFile({
|
|
341
349
|
path: "icons.tsx",
|
|
342
350
|
content: `
|
|
@@ -429,7 +437,7 @@ export function getRightRenderContent (opts: {
|
|
|
429
437
|
label: (
|
|
430
438
|
<>
|
|
431
439
|
<LogoutOutlined />
|
|
432
|
-
|
|
440
|
+
退出登录
|
|
433
441
|
</>
|
|
434
442
|
),
|
|
435
443
|
onClick: () => {
|
|
@@ -439,7 +447,7 @@ export function getRightRenderContent (opts: {
|
|
|
439
447
|
],
|
|
440
448
|
};
|
|
441
449
|
|
|
442
|
-
// antd@5
|
|
450
|
+
// antd@5 和 4.24 之后推荐使用 menu,性能更好
|
|
443
451
|
const dropdownProps =
|
|
444
452
|
version.startsWith("5.") || version.startsWith("4.24.")
|
|
445
453
|
? { menu: langMenu }
|
|
@@ -473,7 +481,7 @@ export function getRightRenderContent (opts: {
|
|
|
473
481
|
content: `
|
|
474
482
|
${antdVersion.startsWith("5") ? "" : "@import '~antd/es/style/themes/default.less';"}
|
|
475
483
|
@media screen and (max-width: 480px) {
|
|
476
|
-
//
|
|
484
|
+
// 在小屏幕的时候可以有更好的体验
|
|
477
485
|
.umi-plugin-layout-container {
|
|
478
486
|
width: 100% !important;
|
|
479
487
|
}
|
|
@@ -645,10 +653,10 @@ const Exception: React.FC<{
|
|
|
645
653
|
<Result
|
|
646
654
|
status={props.route ? '403' : '404'}
|
|
647
655
|
title={props.route ? '403' : '404'}
|
|
648
|
-
subTitle={props.route ? '
|
|
656
|
+
subTitle={props.route ? '抱歉,你无权访问该页面' : '抱歉,你访问的页面不存在'}
|
|
649
657
|
extra={
|
|
650
658
|
<Button type="primary" onClick={() => history.push('/')}>
|
|
651
|
-
|
|
659
|
+
返回首页
|
|
652
660
|
</Button>
|
|
653
661
|
}
|
|
654
662
|
/>
|
package/dist/locale.js
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/locale.ts
|
|
@@ -49,31 +52,41 @@ var locale_default = (api) => {
|
|
|
49
52
|
key: "locale",
|
|
50
53
|
config: {
|
|
51
54
|
schema(Joi) {
|
|
52
|
-
return Joi.alternatives().try(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
return Joi.alternatives().try(
|
|
56
|
+
Joi.object({
|
|
57
|
+
default: Joi.string(),
|
|
58
|
+
useLocalStorage: Joi.boolean(),
|
|
59
|
+
baseNavigator: Joi.boolean(),
|
|
60
|
+
title: Joi.boolean(),
|
|
61
|
+
antd: Joi.boolean(),
|
|
62
|
+
baseSeparator: Joi.string()
|
|
63
|
+
}),
|
|
64
|
+
Joi.boolean().invalid(true)
|
|
65
|
+
);
|
|
60
66
|
}
|
|
61
67
|
},
|
|
62
68
|
enableBy: api.EnableBy.config
|
|
63
69
|
});
|
|
64
|
-
const reactIntlPkgPath = (0, import_plugin_utils.winPath)(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
+
const reactIntlPkgPath = (0, import_plugin_utils.winPath)(
|
|
71
|
+
(0, import_path.dirname)(require.resolve("react-intl/package"))
|
|
72
|
+
);
|
|
73
|
+
api.addEntryImportsAhead(
|
|
74
|
+
() => (0, import_localeUtils.isNeedPolyfill)(api.config.targets || {}) ? [
|
|
75
|
+
{
|
|
76
|
+
source: require.resolve("intl")
|
|
77
|
+
}
|
|
78
|
+
] : []
|
|
79
|
+
);
|
|
70
80
|
const addAntdLocales = async (args) => {
|
|
71
81
|
var _a;
|
|
72
82
|
return await api.applyPlugins({
|
|
73
83
|
key: "addAntdLocales",
|
|
74
84
|
type: api.ApplyPluginsType.add,
|
|
75
85
|
initialValue: [
|
|
76
|
-
`antd/${((_a = api.config) == null ? void 0 : _a.ssr) ? "lib" : "es"}/locale/${(0, import_localeUtils.getAntdLocale)(
|
|
86
|
+
`antd/${((_a = api.config) == null ? void 0 : _a.ssr) ? "lib" : "es"}/locale/${(0, import_localeUtils.getAntdLocale)(
|
|
87
|
+
args.lang,
|
|
88
|
+
args.country
|
|
89
|
+
)}`
|
|
77
90
|
],
|
|
78
91
|
args
|
|
79
92
|
});
|
|
@@ -92,10 +105,17 @@ var locale_default = (api) => {
|
|
|
92
105
|
};
|
|
93
106
|
api.onGenerateFiles(async () => {
|
|
94
107
|
var _a, _b, _c, _d;
|
|
95
|
-
const localeTpl = (0, import_fs.readFileSync)(
|
|
108
|
+
const localeTpl = (0, import_fs.readFileSync)(
|
|
109
|
+
(0, import_path.join)(__dirname, "../libs/locale/locale.tpl"),
|
|
110
|
+
"utf-8"
|
|
111
|
+
);
|
|
96
112
|
const resolveKey = api.config.moment2dayjs ? "dayjs" : "moment";
|
|
97
|
-
const momentPkgPath = (0, import_plugin_utils.winPath)(
|
|
98
|
-
|
|
113
|
+
const momentPkgPath = (0, import_plugin_utils.winPath)(
|
|
114
|
+
(0, import_path.dirname)(require.resolve(`${resolveKey}/package.json`))
|
|
115
|
+
);
|
|
116
|
+
const EventEmitterPkg = (0, import_plugin_utils.winPath)(
|
|
117
|
+
(0, import_path.dirname)(require.resolve("event-emitter/package"))
|
|
118
|
+
);
|
|
99
119
|
const { baseSeparator, baseNavigator, antd, title, useLocalStorage } = {
|
|
100
120
|
...defaultConfig,
|
|
101
121
|
...api.config.locale
|
|
@@ -117,10 +137,12 @@ var locale_default = (api) => {
|
|
|
117
137
|
let DefaultAntdLocales = [];
|
|
118
138
|
if (!antdLocales.length && ((_c = api.config.locale) == null ? void 0 : _c.antd)) {
|
|
119
139
|
const [lang, country = ""] = defaultLocale.split(baseSeparator);
|
|
120
|
-
DefaultAntdLocales = import_plugin_utils.lodash.uniq(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
140
|
+
DefaultAntdLocales = import_plugin_utils.lodash.uniq(
|
|
141
|
+
await addAntdLocales({
|
|
142
|
+
lang,
|
|
143
|
+
country
|
|
144
|
+
})
|
|
145
|
+
);
|
|
124
146
|
}
|
|
125
147
|
const NormalizeAntdLocalesName = function() {
|
|
126
148
|
return packageNormalize(this);
|
|
@@ -140,7 +162,10 @@ var locale_default = (api) => {
|
|
|
140
162
|
}),
|
|
141
163
|
path: "locale.tsx"
|
|
142
164
|
});
|
|
143
|
-
const localeExportsTpl = (0, import_fs.readFileSync)(
|
|
165
|
+
const localeExportsTpl = (0, import_fs.readFileSync)(
|
|
166
|
+
(0, import_path.join)(__dirname, "../libs/locale/localeExports.tpl"),
|
|
167
|
+
"utf-8"
|
|
168
|
+
);
|
|
144
169
|
const localeDirName = "locales";
|
|
145
170
|
const localeDirPath = (0, import_path.join)(api.paths.absSrcPath, localeDirName);
|
|
146
171
|
api.writeTmpFile({
|
|
@@ -169,14 +194,20 @@ var locale_default = (api) => {
|
|
|
169
194
|
reactIntlPkgPath
|
|
170
195
|
})
|
|
171
196
|
});
|
|
172
|
-
const runtimeTpl = (0, import_fs.readFileSync)(
|
|
197
|
+
const runtimeTpl = (0, import_fs.readFileSync)(
|
|
198
|
+
(0, import_path.join)(__dirname, "../libs/locale/runtime.tpl"),
|
|
199
|
+
"utf-8"
|
|
200
|
+
);
|
|
173
201
|
api.writeTmpFile({
|
|
174
202
|
path: "runtime.tsx",
|
|
175
203
|
content: import_plugin_utils.Mustache.render(runtimeTpl, {
|
|
176
204
|
Title: !!title
|
|
177
205
|
})
|
|
178
206
|
});
|
|
179
|
-
const selectLang = (0, import_fs.readFileSync)(
|
|
207
|
+
const selectLang = (0, import_fs.readFileSync)(
|
|
208
|
+
(0, import_path.join)(__dirname, "../libs/locale/SelectLang.tpl"),
|
|
209
|
+
"utf-8"
|
|
210
|
+
);
|
|
180
211
|
api.writeTmpFile({
|
|
181
212
|
path: "SelectLang.tsx",
|
|
182
213
|
content: import_plugin_utils.Mustache.render(selectLang, {
|
package/dist/mf.js
CHANGED
|
@@ -36,13 +36,15 @@ function mf(api) {
|
|
|
36
36
|
schema(Joi) {
|
|
37
37
|
return Joi.object({
|
|
38
38
|
name: Joi.string(),
|
|
39
|
-
remotes: Joi.array().items(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
remotes: Joi.array().items(
|
|
40
|
+
Joi.object({
|
|
41
|
+
aliasName: Joi.string(),
|
|
42
|
+
name: Joi.string().required(),
|
|
43
|
+
entry: Joi.string(),
|
|
44
|
+
entries: Joi.object(),
|
|
45
|
+
keyResolver: Joi.string()
|
|
46
|
+
})
|
|
47
|
+
),
|
|
46
48
|
shared: Joi.object(),
|
|
47
49
|
library: Joi.object()
|
|
48
50
|
});
|
|
@@ -55,7 +57,9 @@ function mf(api) {
|
|
|
55
57
|
const remotes = formatRemotes();
|
|
56
58
|
const shared = getShared();
|
|
57
59
|
if (isEmpty(remotes) && isEmpty(exposes)) {
|
|
58
|
-
api.logger.warn(
|
|
60
|
+
api.logger.warn(
|
|
61
|
+
"ModuleFederation exposes and remotes are empty, plugin will not work"
|
|
62
|
+
);
|
|
59
63
|
return config;
|
|
60
64
|
}
|
|
61
65
|
if (!isEmpty(remotes)) {
|
|
@@ -66,7 +70,11 @@ function mf(api) {
|
|
|
66
70
|
let name = "_";
|
|
67
71
|
if (!isEmpty(exposes)) {
|
|
68
72
|
name = mfName();
|
|
69
|
-
addMFEntry(
|
|
73
|
+
addMFEntry(
|
|
74
|
+
config,
|
|
75
|
+
name,
|
|
76
|
+
(0, import_path.join)(api.paths.absTmpPath, "plugin-mf", mfSetupPathFileName)
|
|
77
|
+
);
|
|
70
78
|
}
|
|
71
79
|
const mfConfig = {
|
|
72
80
|
name,
|
|
@@ -78,7 +86,11 @@ function mf(api) {
|
|
|
78
86
|
};
|
|
79
87
|
const { ModuleFederationPlugin } = webpack.container;
|
|
80
88
|
config.plugins.push(new ModuleFederationPlugin(mfConfig));
|
|
81
|
-
api.logger.debug(
|
|
89
|
+
api.logger.debug(
|
|
90
|
+
`ModuleFederationPlugin is enabled with config ${JSON.stringify(
|
|
91
|
+
mfConfig
|
|
92
|
+
)}`
|
|
93
|
+
);
|
|
82
94
|
return config;
|
|
83
95
|
});
|
|
84
96
|
api.onGenerateFiles(() => {
|
|
@@ -110,7 +122,9 @@ function mf(api) {
|
|
|
110
122
|
const aliasName = remote.aliasName || remote.name;
|
|
111
123
|
const r = formatRemote(remote);
|
|
112
124
|
if (memo[aliasName]) {
|
|
113
|
-
return api.logger.error(
|
|
125
|
+
return api.logger.error(
|
|
126
|
+
`${aliasName} already set as ${memo[aliasName]}, new value ${r} will be ignored`
|
|
127
|
+
);
|
|
114
128
|
}
|
|
115
129
|
memo[aliasName] = r;
|
|
116
130
|
});
|
|
@@ -162,9 +176,13 @@ function mf(api) {
|
|
|
162
176
|
const dir = (0, import_fs.opendirSync)(exposesPath);
|
|
163
177
|
for await (const dirent of dir) {
|
|
164
178
|
if (dirent.isDirectory()) {
|
|
165
|
-
exposes["./" + dirent.name] = (0, import_plugin_utils.winPath)(
|
|
179
|
+
exposes["./" + dirent.name] = (0, import_plugin_utils.winPath)(
|
|
180
|
+
(0, import_path.join)(api.paths.absSrcPath, "exposes", dirent.name)
|
|
181
|
+
);
|
|
166
182
|
} else {
|
|
167
|
-
api.logger.warn(
|
|
183
|
+
api.logger.warn(
|
|
184
|
+
`${dirent.name} is not a directory, ignore in ModuleFederation expose`
|
|
185
|
+
);
|
|
168
186
|
}
|
|
169
187
|
}
|
|
170
188
|
return exposes;
|
|
@@ -172,7 +190,9 @@ function mf(api) {
|
|
|
172
190
|
function mfName() {
|
|
173
191
|
const name = api.config.mf.name;
|
|
174
192
|
if (!name) {
|
|
175
|
-
api.logger.warn(
|
|
193
|
+
api.logger.warn(
|
|
194
|
+
`module federation name is not defined , "unNamedMF" will be used`
|
|
195
|
+
);
|
|
176
196
|
}
|
|
177
197
|
return name || "unNamedMF";
|
|
178
198
|
}
|
|
@@ -182,7 +202,9 @@ function mf(api) {
|
|
|
182
202
|
}
|
|
183
203
|
function changeUmiEntry(config) {
|
|
184
204
|
const { entry } = config;
|
|
185
|
-
const asyncEntryPath = (0, import_plugin_utils.winPath)(
|
|
205
|
+
const asyncEntryPath = (0, import_plugin_utils.winPath)(
|
|
206
|
+
(0, import_path.join)(api.paths.absTmpPath, "plugin-mf", mfAsyncEntryFileName)
|
|
207
|
+
);
|
|
186
208
|
if (entry.umi) {
|
|
187
209
|
if (typeof entry.umi === "string") {
|
|
188
210
|
entry.umi = asyncEntryPath;
|
|
@@ -191,7 +213,9 @@ function mf(api) {
|
|
|
191
213
|
if (i >= 0) {
|
|
192
214
|
entry.umi[i] = asyncEntryPath;
|
|
193
215
|
} else {
|
|
194
|
-
api.logger.info(
|
|
216
|
+
api.logger.info(
|
|
217
|
+
`umi.ts not found in entry.umi ${JSON.stringify(entry.umi)}`
|
|
218
|
+
);
|
|
195
219
|
}
|
|
196
220
|
}
|
|
197
221
|
} else {
|
package/dist/model.js
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/model.ts
|
|
@@ -35,9 +38,12 @@ var model_default = (api) => {
|
|
|
35
38
|
api.describe({
|
|
36
39
|
config: {
|
|
37
40
|
schema(Joi) {
|
|
38
|
-
return Joi.alternatives().try(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
return Joi.alternatives().try(
|
|
42
|
+
Joi.object({
|
|
43
|
+
extraModels: Joi.array().items(Joi.string())
|
|
44
|
+
}),
|
|
45
|
+
Joi.boolean().invalid(true)
|
|
46
|
+
);
|
|
41
47
|
}
|
|
42
48
|
},
|
|
43
49
|
enableBy: api.EnableBy.config
|
|
@@ -48,7 +54,10 @@ var model_default = (api) => {
|
|
|
48
54
|
path: "model.ts",
|
|
49
55
|
content: import_modelUtils.ModelUtils.getModelsContent(models)
|
|
50
56
|
});
|
|
51
|
-
const indexContent = (0, import_fs.readFileSync)(
|
|
57
|
+
const indexContent = (0, import_fs.readFileSync)(
|
|
58
|
+
(0, import_path.join)(__dirname, "../libs/model.tsx"),
|
|
59
|
+
"utf-8"
|
|
60
|
+
).replace("fast-deep-equal", (0, import_plugin_utils.winPath)(require.resolve("fast-deep-equal")));
|
|
52
61
|
api.writeTmpFile({
|
|
53
62
|
path: "index.tsx",
|
|
54
63
|
content: indexContent
|