@umijs/plugins 4.0.8 → 4.0.11
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 +3 -3
- package/dist/analytics.js +3 -3
- package/dist/antd.js +5 -5
- package/dist/dva.js +26 -3
- package/dist/icons.js +1 -1
- package/dist/initial-state.js +12 -3
- package/dist/layout.js +44 -12
- package/dist/locale.js +12 -12
- package/dist/mf.d.ts +2 -0
- package/dist/mf.js +197 -0
- package/dist/model.js +3 -3
- package/dist/moment2dayjs.js +6 -6
- package/dist/qiankun/constants.js +1 -1
- package/dist/qiankun/master.js +17 -1
- package/dist/qiankun/slave.js +26 -1
- package/dist/qiankun.js +7 -7
- package/dist/request.js +19 -9
- package/dist/tailwindcss.js +7 -3
- package/dist/unocss.js +3 -3
- package/dist/utils/astUtils.js +1 -1
- package/dist/utils/localeUtils.js +1 -1
- package/dist/utils/modelUtils.js +1 -1
- package/dist/utils/resolveProjectDep.js +1 -1
- package/dist/utils/withTmpPath.js +1 -1
- package/libs/locale/localeExports.tpl +7 -3
- package/libs/qiankun/master/MicroApp.tsx +8 -2
- package/libs/qiankun/master/types.ts +1 -1
- package/libs/qiankun/slave/lifecycles.ts +14 -6
- package/package.json +6 -6
package/dist/access.js
CHANGED
|
@@ -19,7 +19,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
21
|
|
|
22
|
-
// access.ts
|
|
22
|
+
// src/access.ts
|
|
23
23
|
var access_exports = {};
|
|
24
24
|
__export(access_exports, {
|
|
25
25
|
default: () => access_default
|
|
@@ -31,8 +31,8 @@ var import_withTmpPath = require("./utils/withTmpPath");
|
|
|
31
31
|
var access_default = (api) => {
|
|
32
32
|
api.describe({
|
|
33
33
|
config: {
|
|
34
|
-
schema(
|
|
35
|
-
return
|
|
34
|
+
schema(Joi) {
|
|
35
|
+
return Joi.alternatives().try(Joi.object(), Joi.boolean().invalid(true));
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
enableBy: api.EnableBy.config
|
package/dist/analytics.js
CHANGED
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// analytics.ts
|
|
19
|
+
// src/analytics.ts
|
|
20
20
|
var analytics_exports = {};
|
|
21
21
|
__export(analytics_exports, {
|
|
22
22
|
default: () => analytics_default
|
|
@@ -30,8 +30,8 @@ var analytics_default = (api) => {
|
|
|
30
30
|
api.describe({
|
|
31
31
|
key: "analytics",
|
|
32
32
|
config: {
|
|
33
|
-
schema(
|
|
34
|
-
return
|
|
33
|
+
schema(Joi) {
|
|
34
|
+
return Joi.alternatives().try(Joi.object(), Joi.boolean().invalid(true));
|
|
35
35
|
},
|
|
36
36
|
onChange: api.ConfigChangeType.reload
|
|
37
37
|
},
|
package/dist/antd.js
CHANGED
|
@@ -33,7 +33,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
33
33
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
34
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
35
|
|
|
36
|
-
// antd.ts
|
|
36
|
+
// src/antd.ts
|
|
37
37
|
var antd_exports = {};
|
|
38
38
|
__export(antd_exports, {
|
|
39
39
|
default: () => antd_default
|
|
@@ -56,13 +56,13 @@ var antd_default = (api) => {
|
|
|
56
56
|
api.describe({
|
|
57
57
|
config: {
|
|
58
58
|
schema(Joi) {
|
|
59
|
-
return Joi.object({
|
|
59
|
+
return Joi.alternatives().try(Joi.object({
|
|
60
60
|
configProvider: Joi.object(),
|
|
61
61
|
dark: Joi.boolean(),
|
|
62
62
|
compact: Joi.boolean(),
|
|
63
63
|
import: Joi.boolean(),
|
|
64
64
|
style: Joi.string().allow("less", "css")
|
|
65
|
-
});
|
|
65
|
+
}), Joi.boolean().invalid(true));
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
68
|
enableBy({ userConfig }) {
|
|
@@ -85,10 +85,10 @@ var antd_default = (api) => {
|
|
|
85
85
|
});
|
|
86
86
|
api.modifyConfig((memo) => {
|
|
87
87
|
checkPkgPath();
|
|
88
|
-
|
|
88
|
+
let antd = memo.antd || {};
|
|
89
89
|
if (process.env.UMI_PLUGIN_ANTD_ENABLE) {
|
|
90
90
|
const { defaultConfig } = JSON.parse(process.env.UMI_PLUGIN_ANTD_ENABLE);
|
|
91
|
-
Object.assign(
|
|
91
|
+
antd = Object.assign(defaultConfig, antd);
|
|
92
92
|
}
|
|
93
93
|
memo.alias.antd = pkgPath;
|
|
94
94
|
if (antd.dayjs) {
|
package/dist/dva.js
CHANGED
|
@@ -19,7 +19,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
21
|
|
|
22
|
-
// dva.ts
|
|
22
|
+
// src/dva.ts
|
|
23
23
|
var dva_exports = {};
|
|
24
24
|
__export(dva_exports, {
|
|
25
25
|
default: () => dva_default,
|
|
@@ -30,6 +30,7 @@ module.exports = __toCommonJS(dva_exports);
|
|
|
30
30
|
var t = __toESM(require("@umijs/bundler-utils/compiled/babel/types"));
|
|
31
31
|
var import_utils = require("@umijs/utils");
|
|
32
32
|
var import_path = require("path");
|
|
33
|
+
var import_umi = require("umi");
|
|
33
34
|
var import_plugin_utils = require("umi/plugin-utils");
|
|
34
35
|
var import_modelUtils = require("./utils/modelUtils");
|
|
35
36
|
var import_withTmpPath = require("./utils/withTmpPath");
|
|
@@ -38,10 +39,10 @@ var dva_default = (api) => {
|
|
|
38
39
|
api.describe({
|
|
39
40
|
config: {
|
|
40
41
|
schema(Joi) {
|
|
41
|
-
return Joi.object({
|
|
42
|
+
return Joi.alternatives().try(Joi.object({
|
|
42
43
|
extraModels: Joi.array().items(Joi.string()),
|
|
43
44
|
immer: Joi.object()
|
|
44
|
-
});
|
|
45
|
+
}), Joi.boolean().invalid(true));
|
|
45
46
|
}
|
|
46
47
|
},
|
|
47
48
|
enableBy: api.EnableBy.config
|
|
@@ -65,6 +66,28 @@ var dva_default = (api) => {
|
|
|
65
66
|
path: "models.ts",
|
|
66
67
|
content: import_modelUtils.ModelUtils.getModelsContent(models)
|
|
67
68
|
});
|
|
69
|
+
api.writeTmpFile({
|
|
70
|
+
path: import_umi.RUNTIME_TYPE_FILE_NAME,
|
|
71
|
+
content: `
|
|
72
|
+
export interface IRuntimeConfig {
|
|
73
|
+
dva?: {
|
|
74
|
+
config?: {
|
|
75
|
+
initialState?: Record<string, any>;
|
|
76
|
+
onError?: any;
|
|
77
|
+
onStateChange?: any;
|
|
78
|
+
onAction?: any;
|
|
79
|
+
onHmr?: any;
|
|
80
|
+
onReducer?: any;
|
|
81
|
+
onEffect?: any;
|
|
82
|
+
extraReducers?: any;
|
|
83
|
+
extraEnhancers?: any;
|
|
84
|
+
[key: string]: any;
|
|
85
|
+
},
|
|
86
|
+
plugins?: string[];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
`
|
|
90
|
+
});
|
|
68
91
|
api.writeTmpFile({
|
|
69
92
|
path: "dva.tsx",
|
|
70
93
|
tpl: `
|
package/dist/icons.js
CHANGED
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// icons.ts
|
|
19
|
+
// src/icons.ts
|
|
20
20
|
var icons_exports = {};
|
|
21
21
|
__export(icons_exports, {
|
|
22
22
|
default: () => icons_default
|
package/dist/initial-state.js
CHANGED
|
@@ -16,20 +16,21 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// initial-state.ts
|
|
19
|
+
// src/initial-state.ts
|
|
20
20
|
var initial_state_exports = {};
|
|
21
21
|
__export(initial_state_exports, {
|
|
22
22
|
default: () => initial_state_default
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(initial_state_exports);
|
|
25
|
+
var import_umi = require("umi");
|
|
25
26
|
var import_withTmpPath = require("./utils/withTmpPath");
|
|
26
27
|
var initial_state_default = (api) => {
|
|
27
28
|
api.describe({
|
|
28
29
|
config: {
|
|
29
30
|
schema(Joi) {
|
|
30
|
-
return Joi.object({
|
|
31
|
+
return Joi.alternatives().try(Joi.object({
|
|
31
32
|
loading: Joi.string()
|
|
32
|
-
});
|
|
33
|
+
}), Joi.boolean().invalid(true));
|
|
33
34
|
}
|
|
34
35
|
},
|
|
35
36
|
enableBy: api.EnableBy.config
|
|
@@ -132,6 +133,14 @@ import React from 'react';
|
|
|
132
133
|
import Provider from './Provider';
|
|
133
134
|
export function dataflowProvider(container) {
|
|
134
135
|
return <Provider>{ container }</Provider>;
|
|
136
|
+
}
|
|
137
|
+
`
|
|
138
|
+
});
|
|
139
|
+
api.writeTmpFile({
|
|
140
|
+
path: import_umi.RUNTIME_TYPE_FILE_NAME,
|
|
141
|
+
content: `
|
|
142
|
+
export interface IRuntimeConfig {
|
|
143
|
+
getInitialState?: () => Promise<Record<string, any>>
|
|
135
144
|
}
|
|
136
145
|
`
|
|
137
146
|
});
|
package/dist/layout.js
CHANGED
|
@@ -19,7 +19,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
21
|
|
|
22
|
-
// layout.ts
|
|
22
|
+
// src/layout.ts
|
|
23
23
|
var layout_exports = {};
|
|
24
24
|
__export(layout_exports, {
|
|
25
25
|
default: () => layout_default
|
|
@@ -28,14 +28,15 @@ module.exports = __toCommonJS(layout_exports);
|
|
|
28
28
|
var allIcons = __toESM(require("@ant-design/icons"));
|
|
29
29
|
var import_fs = require("fs");
|
|
30
30
|
var import_path = require("path");
|
|
31
|
+
var import_umi = require("umi");
|
|
31
32
|
var import_plugin_utils = require("umi/plugin-utils");
|
|
32
33
|
var import_withTmpPath = require("./utils/withTmpPath");
|
|
33
34
|
var layout_default = (api) => {
|
|
34
35
|
api.describe({
|
|
35
36
|
key: "layout",
|
|
36
37
|
config: {
|
|
37
|
-
schema(
|
|
38
|
-
return
|
|
38
|
+
schema(Joi) {
|
|
39
|
+
return Joi.alternatives().try(Joi.object(), Joi.boolean().invalid(true));
|
|
39
40
|
},
|
|
40
41
|
onChange: api.ConfigChangeType.regenerateTmpFiles
|
|
41
42
|
},
|
|
@@ -247,20 +248,49 @@ const { formatMessage } = useIntl();
|
|
|
247
248
|
api.writeTmpFile({
|
|
248
249
|
path: "types.d.ts",
|
|
249
250
|
content: `
|
|
250
|
-
import type { ProLayoutProps } from "${pkgPath || "@ant-design/pro-layout"}";
|
|
251
|
+
import type { ProLayoutProps, HeaderProps } from "${pkgPath || "@ant-design/pro-layout"}";
|
|
251
252
|
${hasInitialStatePlugin ? `import type InitialStateType from '@@/plugin-initialState/@@initialState';
|
|
252
253
|
type InitDataType = ReturnType<typeof InitialStateType>;
|
|
253
254
|
` : "type InitDataType = any;"}
|
|
254
255
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
) =>
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
256
|
+
import { IConfigFromPlugins } from '@@/core/pluginConfig';
|
|
257
|
+
|
|
258
|
+
export type RunTimeLayoutConfig = (initData: InitDataType) => Omit<
|
|
259
|
+
ProLayoutProps,
|
|
260
|
+
'rightContentRender'
|
|
261
|
+
> & {
|
|
262
|
+
childrenRender?: (dom: JSX.Element, props: ProLayoutProps) => React.ReactNode;
|
|
263
|
+
unAccessible?: JSX.Element;
|
|
264
|
+
noFound?: JSX.Element;
|
|
265
|
+
logout?: (initialState: InitDataType['initialState']) => Promise<void> | void;
|
|
266
|
+
rightContentRender?: (
|
|
267
|
+
headerProps: HeaderProps,
|
|
268
|
+
dom: JSX.Element,
|
|
269
|
+
props: {
|
|
270
|
+
userConfig: IConfigFromPlugins['layout'];
|
|
271
|
+
runtimeConfig: RunTimeLayoutConfig;
|
|
272
|
+
loading: InitDataType['loading'];
|
|
273
|
+
initialState: InitDataType['initialState'];
|
|
274
|
+
setInitialState: InitDataType['setInitialState'];
|
|
275
|
+
},
|
|
276
|
+
) => JSX.Element;
|
|
277
|
+
rightRender?: (
|
|
278
|
+
initialState: InitDataType['initialState'],
|
|
279
|
+
setInitialState: InitDataType['setInitialState'],
|
|
280
|
+
runtimeConfig: RunTimeLayoutConfig,
|
|
281
|
+
) => JSX.Element;
|
|
261
282
|
};
|
|
262
283
|
`
|
|
263
284
|
});
|
|
285
|
+
api.writeTmpFile({
|
|
286
|
+
path: import_umi.RUNTIME_TYPE_FILE_NAME,
|
|
287
|
+
content: `
|
|
288
|
+
import type { RunTimeLayoutConfig } from './types.d';
|
|
289
|
+
export interface IRuntimeConfig {
|
|
290
|
+
layout?: RunTimeLayoutConfig
|
|
291
|
+
}
|
|
292
|
+
`
|
|
293
|
+
});
|
|
264
294
|
const iconsMap = Object.keys(api.appData.routes).reduce((memo, id) => {
|
|
265
295
|
const { icon } = api.appData.routes[id];
|
|
266
296
|
if (icon) {
|
|
@@ -560,11 +590,13 @@ const Exception: React.FC<{
|
|
|
560
590
|
route?: IRoute;
|
|
561
591
|
notFound?: React.ReactNode;
|
|
562
592
|
noAccessible?: React.ReactNode;
|
|
593
|
+
unAccessible?: React.ReactNode;
|
|
594
|
+
noFound?: React.ReactNode;
|
|
563
595
|
}> = (props) => (
|
|
564
596
|
// render custom 404
|
|
565
|
-
(!props.route && props.notFound) ||
|
|
597
|
+
(!props.route && (props.noFound || props.notFound)) ||
|
|
566
598
|
// render custom 403
|
|
567
|
-
(props.route.unaccessible && props.noAccessible) ||
|
|
599
|
+
(props.route.unaccessible && (props.unAccessible || props.noAccessible)) ||
|
|
568
600
|
// render default exception
|
|
569
601
|
((!props.route || props.route.unaccessible) && (
|
|
570
602
|
<Result
|
package/dist/locale.js
CHANGED
|
@@ -36,7 +36,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
36
36
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
37
37
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
38
|
|
|
39
|
-
// locale.ts
|
|
39
|
+
// src/locale.ts
|
|
40
40
|
var locale_exports = {};
|
|
41
41
|
__export(locale_exports, {
|
|
42
42
|
default: () => locale_default,
|
|
@@ -65,15 +65,15 @@ var locale_default = (api) => {
|
|
|
65
65
|
api.describe({
|
|
66
66
|
key: "locale",
|
|
67
67
|
config: {
|
|
68
|
-
schema(
|
|
69
|
-
return
|
|
70
|
-
default:
|
|
71
|
-
useLocalStorage:
|
|
72
|
-
baseNavigator:
|
|
73
|
-
title:
|
|
74
|
-
antd:
|
|
75
|
-
baseSeparator:
|
|
76
|
-
});
|
|
68
|
+
schema(Joi) {
|
|
69
|
+
return Joi.alternatives().try(Joi.object({
|
|
70
|
+
default: Joi.string(),
|
|
71
|
+
useLocalStorage: Joi.boolean(),
|
|
72
|
+
baseNavigator: Joi.boolean(),
|
|
73
|
+
title: Joi.boolean(),
|
|
74
|
+
antd: Joi.boolean(),
|
|
75
|
+
baseSeparator: Joi.string()
|
|
76
|
+
}), Joi.boolean().invalid(true));
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
79
|
enableBy: api.EnableBy.config
|
|
@@ -202,8 +202,8 @@ var locale_default = (api) => {
|
|
|
202
202
|
api.writeTmpFile({
|
|
203
203
|
path: "index.ts",
|
|
204
204
|
content: `
|
|
205
|
-
export { addLocale, setLocale, getLocale, getIntl, useIntl, injectIntl, formatMessage, FormattedMessage, getAllLocales } from './localeExports
|
|
206
|
-
export { SelectLang } from './SelectLang
|
|
205
|
+
export { addLocale, setLocale, getLocale, getIntl, useIntl, injectIntl, formatMessage, FormattedMessage, getAllLocales, FormattedDate, FormattedDateParts, FormattedDisplayName, FormattedHTMLMessage, FormattedList, FormattedNumber, FormattedNumberParts, FormattedPlural, FormattedRelativeTime, FormattedTime, FormattedTimeParts, IntlProvider, RawIntlProvider } from './localeExports';
|
|
206
|
+
export { SelectLang } from './SelectLang';
|
|
207
207
|
`
|
|
208
208
|
});
|
|
209
209
|
});
|
package/dist/mf.d.ts
ADDED
package/dist/mf.js
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/mf.ts
|
|
20
|
+
var mf_exports = {};
|
|
21
|
+
__export(mf_exports, {
|
|
22
|
+
default: () => mf
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(mf_exports);
|
|
25
|
+
var import_fs = require("fs");
|
|
26
|
+
var import_path = require("path");
|
|
27
|
+
var import_plugin_utils = require("umi/plugin-utils");
|
|
28
|
+
var { isEmpty } = import_plugin_utils.lodash;
|
|
29
|
+
var mfSetupPathFileName = "_mf_setup-public-path.js";
|
|
30
|
+
var mfAsyncEntryFileName = "asyncEntry.ts";
|
|
31
|
+
function mf(api) {
|
|
32
|
+
api.describe({
|
|
33
|
+
key: "mf",
|
|
34
|
+
config: {
|
|
35
|
+
schema(Joi) {
|
|
36
|
+
return Joi.object({
|
|
37
|
+
name: Joi.string(),
|
|
38
|
+
remotes: Joi.array().items(Joi.object({
|
|
39
|
+
aliasName: Joi.string(),
|
|
40
|
+
name: Joi.string().required(),
|
|
41
|
+
entry: Joi.string(),
|
|
42
|
+
entries: Joi.object(),
|
|
43
|
+
keyResolver: Joi.string()
|
|
44
|
+
})),
|
|
45
|
+
shared: Joi.object(),
|
|
46
|
+
library: Joi.object()
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
enableBy: api.EnableBy.config
|
|
51
|
+
});
|
|
52
|
+
api.modifyWebpackConfig(async (config, { webpack }) => {
|
|
53
|
+
const exposes = await constructExposes();
|
|
54
|
+
const remotes = formatRemotes();
|
|
55
|
+
const shared = getShared();
|
|
56
|
+
if (isEmpty(remotes) && isEmpty(exposes)) {
|
|
57
|
+
api.logger.warn("ModuleFederation exposes and remotes are empty, plugin will not work");
|
|
58
|
+
return config;
|
|
59
|
+
}
|
|
60
|
+
if (!isEmpty(remotes)) {
|
|
61
|
+
if (!api.config.mfsu) {
|
|
62
|
+
changeUmiEntry(config);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
let name = "_";
|
|
66
|
+
if (!isEmpty(exposes)) {
|
|
67
|
+
name = mfName();
|
|
68
|
+
addMFEntry(config, name, (0, import_path.join)(api.paths.absTmpPath, "plugin-mf", mfSetupPathFileName));
|
|
69
|
+
}
|
|
70
|
+
const mfConfig = {
|
|
71
|
+
name,
|
|
72
|
+
remotes,
|
|
73
|
+
filename: "remote.js",
|
|
74
|
+
exposes,
|
|
75
|
+
shared,
|
|
76
|
+
library: api.config.mf.library
|
|
77
|
+
};
|
|
78
|
+
const { ModuleFederationPlugin } = webpack.container;
|
|
79
|
+
config.plugins.push(new ModuleFederationPlugin(mfConfig));
|
|
80
|
+
api.logger.debug(`ModuleFederationPlugin is enabled with config ${JSON.stringify(mfConfig)}`);
|
|
81
|
+
return config;
|
|
82
|
+
});
|
|
83
|
+
api.onGenerateFiles(() => {
|
|
84
|
+
api.writeTmpFile({
|
|
85
|
+
content: `/* infer remote public */;
|
|
86
|
+
__webpack_public_path__ = document.currentScript.src + '/../';`,
|
|
87
|
+
path: mfSetupPathFileName
|
|
88
|
+
});
|
|
89
|
+
if (api.env === "development" && api.config.mfsu) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
api.writeTmpFile({
|
|
93
|
+
content: `import('${(0, import_plugin_utils.winPath)((0, import_path.join)(api.paths.absTmpPath, "umi.ts"))}')`,
|
|
94
|
+
path: mfAsyncEntryFileName
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
function formatRemotes() {
|
|
98
|
+
const { remotes = [] } = api.config.mf;
|
|
99
|
+
const memo = {};
|
|
100
|
+
remotes.forEach((remote) => {
|
|
101
|
+
const aliasName = remote.aliasName || remote.name;
|
|
102
|
+
const r = formatRemote(remote);
|
|
103
|
+
if (memo[aliasName]) {
|
|
104
|
+
return api.logger.error(`${aliasName} already set as ${memo[aliasName]}, new value ${r} will be ignored`);
|
|
105
|
+
}
|
|
106
|
+
memo[aliasName] = r;
|
|
107
|
+
});
|
|
108
|
+
return memo;
|
|
109
|
+
}
|
|
110
|
+
function formatRemote(remote) {
|
|
111
|
+
if (remote.entry) {
|
|
112
|
+
return `${remote.name}@${remote.entry}`;
|
|
113
|
+
}
|
|
114
|
+
if (remote.entries && remote.keyResolver) {
|
|
115
|
+
const dynamicUrl = `promise new Promise(resolve => {
|
|
116
|
+
const entries = ${JSON.stringify(remote.entries)};
|
|
117
|
+
const key = ${remote.keyResolver};
|
|
118
|
+
|
|
119
|
+
const remoteUrlWithVersion = entries[key];
|
|
120
|
+
const script = document.createElement('script')
|
|
121
|
+
script.src = remoteUrlWithVersion
|
|
122
|
+
script.onload = () => {
|
|
123
|
+
// the injected script has loaded and is available on window
|
|
124
|
+
// we can now resolve this Promise
|
|
125
|
+
const proxy = {
|
|
126
|
+
get: (request) => window.${remote.name}.get(request),
|
|
127
|
+
init: (arg) => {
|
|
128
|
+
try {
|
|
129
|
+
return window.${remote.name}.init(arg)
|
|
130
|
+
} catch(e) {
|
|
131
|
+
console.log('remote container already initialized')
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
resolve(proxy)
|
|
136
|
+
}
|
|
137
|
+
// inject this script with the src set to the versioned remoteEntry.js
|
|
138
|
+
document.head.appendChild(script);
|
|
139
|
+
})
|
|
140
|
+
`;
|
|
141
|
+
return dynamicUrl;
|
|
142
|
+
} else {
|
|
143
|
+
api.logger.error("you should provider entry or entries and keyResolver");
|
|
144
|
+
throw Error("Wrong MF#remotes config");
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
async function constructExposes() {
|
|
148
|
+
const exposes = {};
|
|
149
|
+
const exposesPath = (0, import_path.join)(api.paths.absSrcPath, "exposes");
|
|
150
|
+
if (!(0, import_fs.existsSync)(exposesPath)) {
|
|
151
|
+
return exposes;
|
|
152
|
+
}
|
|
153
|
+
const dir = (0, import_fs.opendirSync)(exposesPath);
|
|
154
|
+
for await (const dirent of dir) {
|
|
155
|
+
if (dirent.isDirectory()) {
|
|
156
|
+
exposes["./" + dirent.name] = (0, import_plugin_utils.winPath)((0, import_path.join)(api.paths.absSrcPath, "exposes", dirent.name));
|
|
157
|
+
} else {
|
|
158
|
+
api.logger.warn(`${dirent.name} is not a directory, ignore in ModuleFederation expose`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return exposes;
|
|
162
|
+
}
|
|
163
|
+
function mfName() {
|
|
164
|
+
const name = api.config.mf.name;
|
|
165
|
+
if (!name) {
|
|
166
|
+
api.logger.warn(`module federation name is not defined , "unNamedMF" will be used`);
|
|
167
|
+
}
|
|
168
|
+
return name || "unNamedMF";
|
|
169
|
+
}
|
|
170
|
+
function getShared() {
|
|
171
|
+
const { shared = {} } = api.config.mf;
|
|
172
|
+
return shared;
|
|
173
|
+
}
|
|
174
|
+
function changeUmiEntry(config) {
|
|
175
|
+
const { entry } = config;
|
|
176
|
+
const asyncEntryPath = (0, import_plugin_utils.winPath)((0, import_path.join)(api.paths.absTmpPath, "plugin-mf", mfAsyncEntryFileName));
|
|
177
|
+
if (entry.umi) {
|
|
178
|
+
if (typeof entry.umi === "string") {
|
|
179
|
+
entry.umi = asyncEntryPath;
|
|
180
|
+
} else if (Array.isArray(entry.umi)) {
|
|
181
|
+
const i = entry.umi.findIndex((f) => f.endsWith("umi.ts"));
|
|
182
|
+
if (i >= 0) {
|
|
183
|
+
entry.umi[i] = asyncEntryPath;
|
|
184
|
+
} else {
|
|
185
|
+
api.logger.info(`umi.ts not found in entry.umi ${JSON.stringify(entry.umi)}`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
api.logger.warn("umi entry not found");
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
function addMFEntry(config, mfName2, path) {
|
|
193
|
+
config.entry[mfName2] = path;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
197
|
+
0 && (module.exports = {});
|
package/dist/model.js
CHANGED
|
@@ -19,7 +19,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
21
|
|
|
22
|
-
// model.ts
|
|
22
|
+
// src/model.ts
|
|
23
23
|
var model_exports = {};
|
|
24
24
|
__export(model_exports, {
|
|
25
25
|
default: () => model_default
|
|
@@ -35,9 +35,9 @@ var model_default = (api) => {
|
|
|
35
35
|
api.describe({
|
|
36
36
|
config: {
|
|
37
37
|
schema(Joi) {
|
|
38
|
-
return Joi.object({
|
|
38
|
+
return Joi.alternatives().try(Joi.object({
|
|
39
39
|
extraModels: Joi.array().items(Joi.string())
|
|
40
|
-
});
|
|
40
|
+
}), Joi.boolean().invalid(true));
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
enableBy: api.EnableBy.config
|
package/dist/moment2dayjs.js
CHANGED
|
@@ -19,7 +19,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
21
|
|
|
22
|
-
// moment2dayjs.ts
|
|
22
|
+
// src/moment2dayjs.ts
|
|
23
23
|
var moment2dayjs_exports = {};
|
|
24
24
|
__export(moment2dayjs_exports, {
|
|
25
25
|
default: () => moment2dayjs_default
|
|
@@ -31,11 +31,11 @@ var moment2dayjs_default = (api) => {
|
|
|
31
31
|
api.describe({
|
|
32
32
|
key: "moment2dayjs",
|
|
33
33
|
config: {
|
|
34
|
-
schema(
|
|
35
|
-
return
|
|
36
|
-
preset:
|
|
37
|
-
plugins:
|
|
38
|
-
});
|
|
34
|
+
schema(Joi) {
|
|
35
|
+
return Joi.alternatives().try(Joi.object({
|
|
36
|
+
preset: Joi.string(),
|
|
37
|
+
plugins: Joi.array()
|
|
38
|
+
}), Joi.boolean().invalid(true));
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
enableBy: api.EnableBy.config
|
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// constants.ts
|
|
19
|
+
// src/qiankun/constants.ts
|
|
20
20
|
var constants_exports = {};
|
|
21
21
|
__export(constants_exports, {
|
|
22
22
|
MODEL_EXPORT_NAME: () => MODEL_EXPORT_NAME,
|
package/dist/qiankun/master.js
CHANGED
|
@@ -36,7 +36,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
36
36
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
37
37
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
38
|
|
|
39
|
-
// master.ts
|
|
39
|
+
// src/qiankun/master.ts
|
|
40
40
|
var master_exports = {};
|
|
41
41
|
__export(master_exports, {
|
|
42
42
|
default: () => master_default,
|
|
@@ -45,6 +45,7 @@ __export(master_exports, {
|
|
|
45
45
|
module.exports = __toCommonJS(master_exports);
|
|
46
46
|
var import_fs = require("fs");
|
|
47
47
|
var import_path = require("path");
|
|
48
|
+
var import_umi = require("umi");
|
|
48
49
|
var import_plugin_utils = require("umi/plugin-utils");
|
|
49
50
|
var import_withTmpPath = require("../utils/withTmpPath");
|
|
50
51
|
var import_constants = require("./constants");
|
|
@@ -103,6 +104,21 @@ var master_default = (api) => {
|
|
|
103
104
|
}
|
|
104
105
|
api.onGenerateFiles(() => {
|
|
105
106
|
var _a;
|
|
107
|
+
api.writeTmpFile({
|
|
108
|
+
path: import_umi.RUNTIME_TYPE_FILE_NAME,
|
|
109
|
+
content: `
|
|
110
|
+
import { MasterOptions } from './types'
|
|
111
|
+
type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never };
|
|
112
|
+
type XOR<T, U> = (Without<T, U> & U) | (Without<U, T> & T);
|
|
113
|
+
interface Config {
|
|
114
|
+
master?: MasterOptions;
|
|
115
|
+
}
|
|
116
|
+
export interface IRuntimeConfig {
|
|
117
|
+
qiankun?: XOR<MasterOptions, Config>;
|
|
118
|
+
${import_constants.MODEL_EXPORT_NAME}?: () => Record<string, any>;
|
|
119
|
+
}
|
|
120
|
+
`
|
|
121
|
+
});
|
|
106
122
|
api.writeTmpFile({
|
|
107
123
|
path: "masterOptions.ts",
|
|
108
124
|
content: `
|
package/dist/qiankun/slave.js
CHANGED
|
@@ -36,7 +36,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
36
36
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
37
37
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
38
|
|
|
39
|
-
// slave.ts
|
|
39
|
+
// src/qiankun/slave.ts
|
|
40
40
|
var slave_exports = {};
|
|
41
41
|
__export(slave_exports, {
|
|
42
42
|
default: () => slave_default
|
|
@@ -45,6 +45,7 @@ module.exports = __toCommonJS(slave_exports);
|
|
|
45
45
|
var import_assert = __toESM(require("assert"));
|
|
46
46
|
var import_fs = require("fs");
|
|
47
47
|
var import_path = require("path");
|
|
48
|
+
var import_umi = require("umi");
|
|
48
49
|
var import_plugin_utils = require("umi/plugin-utils");
|
|
49
50
|
var import_withTmpPath = require("../utils/withTmpPath");
|
|
50
51
|
var import_constants = require("./constants");
|
|
@@ -75,6 +76,30 @@ var slave_default = (api) => {
|
|
|
75
76
|
];
|
|
76
77
|
}
|
|
77
78
|
});
|
|
79
|
+
api.onGenerateFiles(() => {
|
|
80
|
+
api.writeTmpFile({
|
|
81
|
+
path: import_umi.RUNTIME_TYPE_FILE_NAME,
|
|
82
|
+
content: `
|
|
83
|
+
interface LifeCycles {
|
|
84
|
+
bootstrap?: (props?: any) => Promise<any>;
|
|
85
|
+
mount?: (props?: any) => Promise<any>;
|
|
86
|
+
unmount?: (props?: any) => Promise<any>;
|
|
87
|
+
update?: (props?: any) => Promise<any>;
|
|
88
|
+
}
|
|
89
|
+
type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never };
|
|
90
|
+
type XOR<T, U> = (Without<T, U> & U) | (Without<U, T> & T);
|
|
91
|
+
interface SlaveOption extends LifeCycles {
|
|
92
|
+
enable?: boolean;
|
|
93
|
+
}
|
|
94
|
+
interface Config {
|
|
95
|
+
slave?: SlaveOption;
|
|
96
|
+
}
|
|
97
|
+
export interface IRuntimeConfig {
|
|
98
|
+
qiankun?: XOR<Config, LifeCycles>
|
|
99
|
+
}
|
|
100
|
+
`
|
|
101
|
+
});
|
|
102
|
+
});
|
|
78
103
|
api.modifyDefaultConfig((memo) => {
|
|
79
104
|
var _a, _b, _c;
|
|
80
105
|
const initialSlaveOptions = __spreadValues(__spreadValues({
|
package/dist/qiankun.js
CHANGED
|
@@ -19,7 +19,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
21
|
|
|
22
|
-
// qiankun.ts
|
|
22
|
+
// src/qiankun.ts
|
|
23
23
|
var qiankun_exports = {};
|
|
24
24
|
__export(qiankun_exports, {
|
|
25
25
|
default: () => qiankun_default
|
|
@@ -28,12 +28,12 @@ module.exports = __toCommonJS(qiankun_exports);
|
|
|
28
28
|
var qiankun_default = (api) => {
|
|
29
29
|
api.describe({
|
|
30
30
|
config: {
|
|
31
|
-
schema(
|
|
32
|
-
return
|
|
33
|
-
slave:
|
|
34
|
-
master:
|
|
35
|
-
externalQiankun:
|
|
36
|
-
});
|
|
31
|
+
schema(Joi) {
|
|
32
|
+
return Joi.alternatives().try(Joi.object().keys({
|
|
33
|
+
slave: Joi.object(),
|
|
34
|
+
master: Joi.object(),
|
|
35
|
+
externalQiankun: Joi.boolean()
|
|
36
|
+
}), Joi.boolean().invalid(true));
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
});
|
package/dist/request.js
CHANGED
|
@@ -19,22 +19,23 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
21
|
|
|
22
|
-
// request.ts
|
|
22
|
+
// src/request.ts
|
|
23
23
|
var request_exports = {};
|
|
24
24
|
__export(request_exports, {
|
|
25
25
|
default: () => request_default
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(request_exports);
|
|
28
28
|
var import_path = require("path");
|
|
29
|
+
var import_umi = require("umi");
|
|
29
30
|
var import_plugin_utils = require("umi/plugin-utils");
|
|
30
31
|
var request_default = (api) => {
|
|
31
32
|
api.describe({
|
|
32
33
|
key: "request",
|
|
33
34
|
config: {
|
|
34
|
-
schema: (
|
|
35
|
-
return
|
|
36
|
-
dataField:
|
|
37
|
-
});
|
|
35
|
+
schema: (Joi) => {
|
|
36
|
+
return Joi.alternatives().try(Joi.object({
|
|
37
|
+
dataField: Joi.string().pattern(/^[a-zA-Z]*$/).allow("")
|
|
38
|
+
}), Joi.boolean().invalid(true));
|
|
38
39
|
}
|
|
39
40
|
},
|
|
40
41
|
enableBy: api.EnableBy.config
|
|
@@ -153,7 +154,7 @@ interface IErrorHandler {
|
|
|
153
154
|
}
|
|
154
155
|
type IRequestInterceptorAxios = (config: RequestOptions) => RequestOptions;
|
|
155
156
|
type IRequestInterceptorUmiRequest = (url: string, config : RequestOptions) => { url: string, options: RequestOptions };
|
|
156
|
-
type IRequestInterceptor = IRequestInterceptorAxios;
|
|
157
|
+
type IRequestInterceptor = IRequestInterceptorAxios | IRequestInterceptorUmiRequest;
|
|
157
158
|
type IErrorInterceptor = (error: Error) => Promise<Error>;
|
|
158
159
|
type IResponseInterceptor = <T = any>(response : AxiosResponse<T>) => AxiosResponse<T> ;
|
|
159
160
|
type IRequestInterceptorTuple = [IRequestInterceptor , IErrorInterceptor] | [ IRequestInterceptor ] | IRequestInterceptor
|
|
@@ -324,11 +325,11 @@ export type {
|
|
|
324
325
|
api.writeTmpFile({
|
|
325
326
|
path: "types.d.ts",
|
|
326
327
|
content: `
|
|
327
|
-
export type {
|
|
328
|
-
RequestConfig,
|
|
328
|
+
export type {
|
|
329
|
+
RequestConfig,
|
|
329
330
|
AxiosInstance,
|
|
330
331
|
AxiosRequestConfig,
|
|
331
|
-
AxiosResponse,
|
|
332
|
+
AxiosResponse,
|
|
332
333
|
AxiosError,
|
|
333
334
|
RequestError,
|
|
334
335
|
ResponseInterceptor } from './request';
|
|
@@ -344,6 +345,15 @@ export {
|
|
|
344
345
|
} from './request';
|
|
345
346
|
`
|
|
346
347
|
});
|
|
348
|
+
api.writeTmpFile({
|
|
349
|
+
path: import_umi.RUNTIME_TYPE_FILE_NAME,
|
|
350
|
+
content: `
|
|
351
|
+
import type { RequestConfig } from './types.d'
|
|
352
|
+
export type IRuntimeConfig = {
|
|
353
|
+
request?: RequestConfig
|
|
354
|
+
};
|
|
355
|
+
`
|
|
356
|
+
});
|
|
347
357
|
});
|
|
348
358
|
};
|
|
349
359
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/tailwindcss.js
CHANGED
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// tailwindcss.ts
|
|
19
|
+
// src/tailwindcss.ts
|
|
20
20
|
var tailwindcss_exports = {};
|
|
21
21
|
__export(tailwindcss_exports, {
|
|
22
22
|
default: () => tailwindcss_default
|
|
@@ -29,7 +29,7 @@ var tailwindcss_default = (api) => {
|
|
|
29
29
|
key: "tailwindcss",
|
|
30
30
|
config: {
|
|
31
31
|
schema(Joi) {
|
|
32
|
-
return Joi.object();
|
|
32
|
+
return Joi.alternatives().try(Joi.object(), Joi.boolean().invalid(true));
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
enableBy: api.EnableBy.config
|
|
@@ -40,15 +40,19 @@ var tailwindcss_default = (api) => {
|
|
|
40
40
|
const inputPath = (0, import_path.join)(api.cwd, "tailwind.css");
|
|
41
41
|
const generatedPath = (0, import_path.join)(api.paths.absTmpPath, outputPath);
|
|
42
42
|
const binPath = (0, import_path.join)(api.cwd, "node_modules/.bin/tailwind");
|
|
43
|
+
const configPath = (0, import_path.join)(process.env.APP_ROOT || api.cwd, "tailwind.config.js");
|
|
43
44
|
return new Promise((resolve) => {
|
|
44
45
|
tailwind = (0, import_plugin_utils.crossSpawn)(`${binPath}`, [
|
|
46
|
+
"-c",
|
|
47
|
+
configPath,
|
|
45
48
|
"-i",
|
|
46
49
|
inputPath,
|
|
47
50
|
"-o",
|
|
48
51
|
generatedPath,
|
|
49
52
|
api.env === "development" ? "--watch" : ""
|
|
50
53
|
], {
|
|
51
|
-
stdio: "inherit"
|
|
54
|
+
stdio: "inherit",
|
|
55
|
+
cwd: process.env.APP_ROOT || api.cwd
|
|
52
56
|
});
|
|
53
57
|
tailwind.on("error", (m) => {
|
|
54
58
|
api.logger.error("tailwindcss service encounter an error: " + m);
|
package/dist/unocss.js
CHANGED
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// unocss.ts
|
|
19
|
+
// src/unocss.ts
|
|
20
20
|
var unocss_exports = {};
|
|
21
21
|
__export(unocss_exports, {
|
|
22
22
|
default: () => unocss_default
|
|
@@ -31,9 +31,9 @@ var unocss_default = (api) => {
|
|
|
31
31
|
key: "unocss",
|
|
32
32
|
config: {
|
|
33
33
|
schema(Joi) {
|
|
34
|
-
return Joi.object({
|
|
34
|
+
return Joi.alternatives().try(Joi.object({
|
|
35
35
|
watch: Joi.array()
|
|
36
|
-
});
|
|
36
|
+
}), Joi.boolean().invalid(true));
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
enableBy: api.EnableBy.config
|
package/dist/utils/astUtils.js
CHANGED
|
@@ -19,7 +19,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
21
|
|
|
22
|
-
// astUtils.ts
|
|
22
|
+
// src/utils/astUtils.ts
|
|
23
23
|
var astUtils_exports = {};
|
|
24
24
|
__export(astUtils_exports, {
|
|
25
25
|
getIdentifierDeclaration: () => getIdentifierDeclaration
|
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// localeUtils.ts
|
|
19
|
+
// src/utils/localeUtils.ts
|
|
20
20
|
var localeUtils_exports = {};
|
|
21
21
|
__export(localeUtils_exports, {
|
|
22
22
|
exactLocalePaths: () => exactLocalePaths,
|
package/dist/utils/modelUtils.js
CHANGED
|
@@ -19,7 +19,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
19
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
21
|
|
|
22
|
-
// modelUtils.ts
|
|
22
|
+
// src/utils/modelUtils.ts
|
|
23
23
|
var modelUtils_exports = {};
|
|
24
24
|
__export(modelUtils_exports, {
|
|
25
25
|
Model: () => Model,
|
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// resolveProjectDep.ts
|
|
19
|
+
// src/utils/resolveProjectDep.ts
|
|
20
20
|
var resolveProjectDep_exports = {};
|
|
21
21
|
__export(resolveProjectDep_exports, {
|
|
22
22
|
resolveProjectDep: () => resolveProjectDep
|
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// withTmpPath.ts
|
|
19
|
+
// src/utils/withTmpPath.ts
|
|
20
20
|
var withTmpPath_exports = {};
|
|
21
21
|
__export(withTmpPath_exports, {
|
|
22
22
|
withTmpPath: () => withTmpPath
|
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
IntlShape,
|
|
4
4
|
MessageDescriptor,
|
|
5
5
|
} from '{{{ reactIntlPkgPath }}}';
|
|
6
|
-
import { ApplyPluginsType } from 'umi';
|
|
7
6
|
import { getPluginManager } from '../core/plugin';
|
|
8
7
|
import EventEmitter from '{{{EventEmitterPkg}}}';
|
|
9
8
|
// @ts-ignore
|
|
@@ -153,7 +152,8 @@ export const setIntl = (locale: string) => {
|
|
|
153
152
|
export const getLocale = () => {
|
|
154
153
|
const runtimeLocale = getPluginManager().applyPlugins({
|
|
155
154
|
key: 'locale',
|
|
156
|
-
|
|
155
|
+
// workaround: 不使用 ApplyPluginsType.modify 是为了避免循环依赖,与 fast-refresh 一起用时会有问题
|
|
156
|
+
type: 'modify',
|
|
157
157
|
initialValue: {},
|
|
158
158
|
});
|
|
159
159
|
// runtime getLocale for user define
|
|
@@ -201,7 +201,8 @@ export const setLocale = (lang: string, realReload: boolean = true) => {
|
|
|
201
201
|
//const { pluginManager } = useAppContext();
|
|
202
202
|
//const runtimeLocale = pluginManagerapplyPlugins({
|
|
203
203
|
// key: 'locale',
|
|
204
|
-
//
|
|
204
|
+
// workaround: 不使用 ApplyPluginsType.modify 是为了避免循环依赖,与 fast-refresh 一起用时会有问题
|
|
205
|
+
// type: 'modify',
|
|
205
206
|
// initialValue: {},
|
|
206
207
|
//});
|
|
207
208
|
|
|
@@ -261,6 +262,9 @@ http://j.mp/37Fkd5Q
|
|
|
261
262
|
);
|
|
262
263
|
firstWaring = false;
|
|
263
264
|
}
|
|
265
|
+
if (!g_intl) {
|
|
266
|
+
setIntl(getLocale());
|
|
267
|
+
}
|
|
264
268
|
return g_intl.formatMessage(descriptor, values);
|
|
265
269
|
};
|
|
266
270
|
|
|
@@ -88,8 +88,14 @@ export const MicroApp = forwardRef(
|
|
|
88
88
|
...propsFromParams
|
|
89
89
|
} = componentProps;
|
|
90
90
|
|
|
91
|
-
//
|
|
92
|
-
|
|
91
|
+
// ref: https://github.com/umijs/plugins/pull/866
|
|
92
|
+
// name 跟 appNameKeyAlias 这两个 key 同时存在时,优先使用 name,避免对存量应用造成 breaking change。
|
|
93
|
+
// 比如 appNameKeyAlias 配置是 id,但之前 id 正好作为普通的 props 使用过,如 <MicroApp name="app" id="123" />
|
|
94
|
+
// 正常场景会优先匹配 appNameKeyAlias 对应的字段,fallback 到 name,避免对已经使用 <MicroApp name="app" /> 的应用造成影响
|
|
95
|
+
const name =
|
|
96
|
+
componentProps.name && componentProps[appNameKeyAlias]
|
|
97
|
+
? componentProps.name
|
|
98
|
+
: componentProps[appNameKeyAlias] || componentProps.name;
|
|
93
99
|
const isCurrentApp = (app: any) =>
|
|
94
100
|
app[appNameKeyAlias] === name || app.name === name;
|
|
95
101
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import { getPluginManager } from '@@/core/plugin';
|
|
3
3
|
import ReactDOM from 'react-dom';
|
|
4
|
-
import { ApplyPluginsType } from 'umi';
|
|
4
|
+
import { ApplyPluginsType, __getRoot } from 'umi';
|
|
5
5
|
import { setModelState } from './qiankunModel';
|
|
6
6
|
|
|
7
7
|
const noop = () => {};
|
|
@@ -149,12 +149,20 @@ export function genUpdate() {
|
|
|
149
149
|
|
|
150
150
|
export function genUnmount(mountElementId: string) {
|
|
151
151
|
return async (props: any) => {
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (
|
|
156
|
-
|
|
152
|
+
const root = __getRoot();
|
|
153
|
+
|
|
154
|
+
// support react 18 unmount
|
|
155
|
+
if (typeof root?.unmount === 'function') {
|
|
156
|
+
root.unmount();
|
|
157
|
+
} else {
|
|
158
|
+
const container = props?.container
|
|
159
|
+
? props.container.querySelector(`#${mountElementId}`)
|
|
160
|
+
: document.getElementById(mountElementId);
|
|
161
|
+
if (container) {
|
|
162
|
+
ReactDOM.unmountComponentAtNode(container);
|
|
163
|
+
}
|
|
157
164
|
}
|
|
165
|
+
|
|
158
166
|
const slaveRuntime = await getSlaveRuntime();
|
|
159
167
|
if (slaveRuntime.unmount) await slaveRuntime.unmount(props);
|
|
160
168
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/plugins",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.11",
|
|
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",
|
|
@@ -16,16 +16,16 @@
|
|
|
16
16
|
"libs"
|
|
17
17
|
],
|
|
18
18
|
"scripts": {
|
|
19
|
-
"build": "
|
|
19
|
+
"build": "umi-scripts father build",
|
|
20
20
|
"build:deps": "umi-scripts bundleDeps",
|
|
21
|
-
"dev": "
|
|
21
|
+
"dev": "umi-scripts father dev",
|
|
22
22
|
"test": "umi-scripts jest-turbo"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@ahooksjs/use-request": "^2.0.0",
|
|
26
26
|
"@ant-design/icons": "^4.7.0",
|
|
27
|
-
"@ant-design/pro-layout": "^7.0.1-beta.
|
|
28
|
-
"@umijs/bundler-utils": "4.0.
|
|
27
|
+
"@ant-design/pro-layout": "^7.0.1-beta.28",
|
|
28
|
+
"@umijs/bundler-utils": "4.0.11",
|
|
29
29
|
"antd-dayjs-webpack-plugin": "^1.0.6",
|
|
30
30
|
"axios": "^0.27.2",
|
|
31
31
|
"babel-plugin-import": "^1.13.5",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"warning": "^4.0.3"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"umi": "4.0.
|
|
47
|
+
"umi": "4.0.11"
|
|
48
48
|
},
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public"
|