@umijs/plugins 4.0.64 → 4.0.66
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 +12 -6
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +30 -0
- package/dist/locale.js +6 -4
- package/dist/mf.js +3 -1
- package/dist/qiankun/slave.js +28 -13
- package/dist/utils/modelUtils.js +19 -6
- package/libs/qiankun/master/MicroApp.tsx +13 -15
- package/package.json +4 -4
- package/{tpls/antd-runtime.ts.tpl → templates/antd/runtime.ts.tpl} +33 -20
- /package/{libs → templates}/locale/SelectLang.tpl +0 -0
- /package/{libs → templates}/locale/locale.tpl +0 -0
- /package/{libs → templates}/locale/localeExports.tpl +0 -0
- /package/{libs → templates}/locale/runtime.tpl +0 -0
- /package/{tpls/mf-runtime.ts.tpl → templates/mf/runtime.ts.tpl} +0 -0
package/dist/antd.js
CHANGED
|
@@ -36,8 +36,10 @@ var import_assert = __toESM(require("assert"));
|
|
|
36
36
|
var import_path = require("path");
|
|
37
37
|
var import_umi = require("umi");
|
|
38
38
|
var import_plugin_utils = require("umi/plugin-utils");
|
|
39
|
+
var import_constants = require("./constants");
|
|
39
40
|
var import_resolveProjectDep = require("./utils/resolveProjectDep");
|
|
40
41
|
var import_withTmpPath = require("./utils/withTmpPath");
|
|
42
|
+
var ANTD_TEMPLATES_DIR = (0, import_path.join)(import_constants.TEMPLATES_DIR, "antd");
|
|
41
43
|
var antd_default = (api) => {
|
|
42
44
|
let pkgPath;
|
|
43
45
|
let antdVersion = "4.0.0";
|
|
@@ -176,7 +178,7 @@ var antd_default = (api) => {
|
|
|
176
178
|
configProvider: withConfigProvider && JSON.stringify(api.config.antd.configProvider),
|
|
177
179
|
appConfig: appComponentAvailable && JSON.stringify(api.config.antd.appConfig)
|
|
178
180
|
},
|
|
179
|
-
tplPath: (0, import_path.join)(
|
|
181
|
+
tplPath: (0, import_plugin_utils.winPath)((0, import_path.join)(ANTD_TEMPLATES_DIR, "runtime.ts.tpl"))
|
|
180
182
|
});
|
|
181
183
|
api.writeTmpFile({
|
|
182
184
|
path: "types.d.ts",
|
|
@@ -223,13 +225,17 @@ export type IRuntimeConfig = {
|
|
|
223
225
|
return [];
|
|
224
226
|
});
|
|
225
227
|
api.addEntryImportsAhead(() => {
|
|
228
|
+
const isAntd5 = antdVersion.startsWith("5");
|
|
226
229
|
const style = api.config.antd.style || "less";
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
{
|
|
230
|
+
const imports = [];
|
|
231
|
+
if (isAntd5) {
|
|
232
|
+
imports.push({ source: "antd/dist/reset.css" });
|
|
233
|
+
} else if (!api.config.antd.import || api.appData.vite) {
|
|
234
|
+
imports.push({
|
|
230
235
|
source: style === "less" ? "antd/dist/antd.less" : "antd/dist/antd.css"
|
|
231
|
-
}
|
|
232
|
-
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
return imports;
|
|
233
239
|
});
|
|
234
240
|
};
|
|
235
241
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const TEMPLATES_DIR: string;
|
|
@@ -0,0 +1,30 @@
|
|
|
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/constants.ts
|
|
20
|
+
var constants_exports = {};
|
|
21
|
+
__export(constants_exports, {
|
|
22
|
+
TEMPLATES_DIR: () => TEMPLATES_DIR
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(constants_exports);
|
|
25
|
+
var import_path = require("path");
|
|
26
|
+
var TEMPLATES_DIR = (0, import_path.join)(__dirname, "../templates");
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
TEMPLATES_DIR
|
|
30
|
+
});
|
package/dist/locale.js
CHANGED
|
@@ -37,8 +37,10 @@ var import_fs = require("fs");
|
|
|
37
37
|
var import_path = require("path");
|
|
38
38
|
var import_umi = require("umi");
|
|
39
39
|
var import_plugin_utils = require("umi/plugin-utils");
|
|
40
|
+
var import_constants = require("./constants");
|
|
40
41
|
var import_localeUtils = require("./utils/localeUtils");
|
|
41
42
|
var import_withTmpPath = require("./utils/withTmpPath");
|
|
43
|
+
var LOCALE_TEMPLATES_DIR = (0, import_path.join)(import_constants.TEMPLATES_DIR, "locale");
|
|
42
44
|
var packageNormalize = (packageName) => packageName.replace(/[@\/\-.]/g, "_");
|
|
43
45
|
var locale_default = (api) => {
|
|
44
46
|
let hasAntd = false;
|
|
@@ -108,7 +110,7 @@ var locale_default = (api) => {
|
|
|
108
110
|
api.onGenerateFiles(async () => {
|
|
109
111
|
var _a, _b, _c, _d;
|
|
110
112
|
const localeTpl = (0, import_fs.readFileSync)(
|
|
111
|
-
(0, import_path.join)(
|
|
113
|
+
(0, import_path.join)(LOCALE_TEMPLATES_DIR, "locale.tpl"),
|
|
112
114
|
"utf-8"
|
|
113
115
|
);
|
|
114
116
|
const resolveKey = api.config.moment2dayjs ? "dayjs" : "moment";
|
|
@@ -165,7 +167,7 @@ var locale_default = (api) => {
|
|
|
165
167
|
path: "locale.tsx"
|
|
166
168
|
});
|
|
167
169
|
const localeExportsTpl = (0, import_fs.readFileSync)(
|
|
168
|
-
(0, import_path.join)(
|
|
170
|
+
(0, import_path.join)(LOCALE_TEMPLATES_DIR, "localeExports.tpl"),
|
|
169
171
|
"utf-8"
|
|
170
172
|
);
|
|
171
173
|
const localeDirName = "locales";
|
|
@@ -197,7 +199,7 @@ var locale_default = (api) => {
|
|
|
197
199
|
})
|
|
198
200
|
});
|
|
199
201
|
const runtimeTpl = (0, import_fs.readFileSync)(
|
|
200
|
-
(0, import_path.join)(
|
|
202
|
+
(0, import_path.join)(LOCALE_TEMPLATES_DIR, "runtime.tpl"),
|
|
201
203
|
"utf-8"
|
|
202
204
|
);
|
|
203
205
|
api.writeTmpFile({
|
|
@@ -207,7 +209,7 @@ var locale_default = (api) => {
|
|
|
207
209
|
})
|
|
208
210
|
});
|
|
209
211
|
const selectLang = (0, import_fs.readFileSync)(
|
|
210
|
-
(0, import_path.join)(
|
|
212
|
+
(0, import_path.join)(LOCALE_TEMPLATES_DIR, "SelectLang.tpl"),
|
|
211
213
|
"utf-8"
|
|
212
214
|
);
|
|
213
215
|
api.writeTmpFile({
|
package/dist/mf.js
CHANGED
|
@@ -25,10 +25,12 @@ module.exports = __toCommonJS(mf_exports);
|
|
|
25
25
|
var import_fs = require("fs");
|
|
26
26
|
var import_path = require("path");
|
|
27
27
|
var import_plugin_utils = require("umi/plugin-utils");
|
|
28
|
+
var import_constants = require("./constants");
|
|
28
29
|
var import_mfUtils = require("./utils/mfUtils");
|
|
29
30
|
var { isEmpty } = import_plugin_utils.lodash;
|
|
30
31
|
var mfSetupPathFileName = "_mf_setup-public-path.js";
|
|
31
32
|
var mfAsyncEntryFileName = "asyncEntry.ts";
|
|
33
|
+
var MF_TEMPLATES_DIR = (0, import_path.join)(import_constants.TEMPLATES_DIR, "mf");
|
|
32
34
|
function mf(api) {
|
|
33
35
|
api.describe({
|
|
34
36
|
key: "mf",
|
|
@@ -121,7 +123,7 @@ function mf(api) {
|
|
|
121
123
|
context: {
|
|
122
124
|
remoteCodeString: (0, import_mfUtils.toRemotesCodeString)(remotes)
|
|
123
125
|
},
|
|
124
|
-
tplPath: (0, import_path.join)(
|
|
126
|
+
tplPath: (0, import_plugin_utils.winPath)((0, import_path.join)(MF_TEMPLATES_DIR, "runtime.ts.tpl"))
|
|
125
127
|
});
|
|
126
128
|
if (api.env === "development" && api.config.mfsu) {
|
|
127
129
|
return;
|
package/dist/qiankun/slave.js
CHANGED
|
@@ -48,7 +48,8 @@ function getCurrentLocalDevServerEntry(api, req) {
|
|
|
48
48
|
return `${protocol}://${hostname}${port ? ":" : ""}${port}/local-dev-server`;
|
|
49
49
|
}
|
|
50
50
|
function handleOriginalHtml(api, microAppEntry, originalHtml) {
|
|
51
|
-
|
|
51
|
+
var _a, _b;
|
|
52
|
+
const appName = ((_b = (_a = api.config.qiankun) == null ? void 0 : _a.slave) == null ? void 0 : _b.appName) || api.pkg.name;
|
|
52
53
|
(0, import_assert.default)(
|
|
53
54
|
appName,
|
|
54
55
|
"[@umijs/plugin-qiankun]: You should have name in package.json"
|
|
@@ -262,15 +263,24 @@ export { MicroAppLink } from './MicroAppLink';
|
|
|
262
263
|
key: "onLocalProxyStart",
|
|
263
264
|
type: api.ApplyPluginsType.event
|
|
264
265
|
});
|
|
266
|
+
const modifyLocalProxyOpts = await api.applyPlugins({
|
|
267
|
+
key: "modifyLocalProxyOpts",
|
|
268
|
+
type: api.ApplyPluginsType.modify,
|
|
269
|
+
initialValue: {}
|
|
270
|
+
}) ?? {};
|
|
271
|
+
const localProxyOpts = {
|
|
272
|
+
target: masterEntry,
|
|
273
|
+
secure: false,
|
|
274
|
+
ignorePath: false,
|
|
275
|
+
followRedirects: false,
|
|
276
|
+
changeOrigin: true,
|
|
277
|
+
selfHandleResponse: true,
|
|
278
|
+
...modifyLocalProxyOpts
|
|
279
|
+
};
|
|
265
280
|
return (0, import_http_proxy_middleware.createProxyMiddleware)(
|
|
266
281
|
(pathname) => pathname !== "/local-dev-server",
|
|
267
282
|
{
|
|
268
|
-
|
|
269
|
-
secure: false,
|
|
270
|
-
ignorePath: false,
|
|
271
|
-
followRedirects: false,
|
|
272
|
-
changeOrigin: true,
|
|
273
|
-
selfHandleResponse: true,
|
|
283
|
+
...localProxyOpts,
|
|
274
284
|
onProxyReq(proxyReq) {
|
|
275
285
|
api.applyPlugins({
|
|
276
286
|
key: "onLocalProxyReq",
|
|
@@ -283,13 +293,18 @@ export { MicroAppLink } from './MicroAppLink';
|
|
|
283
293
|
async (responseBuffer, proxyRes, req2, res2) => {
|
|
284
294
|
var _a2;
|
|
285
295
|
if (proxyRes.statusCode === 302) {
|
|
286
|
-
const
|
|
296
|
+
const { ignorePath = false } = localProxyOpts;
|
|
297
|
+
const { hostname, url, protocol } = req2;
|
|
287
298
|
const port = process.env.PORT || ((_a2 = api.appData) == null ? void 0 : _a2.port);
|
|
288
|
-
const
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
299
|
+
const gotoBasePart = `${protocol}://${hostname}:${port}${ignorePath && url ? url : "/"}`;
|
|
300
|
+
const fromBasePart = masterEntry;
|
|
301
|
+
const locationUrl = proxyRes.headers.location || "";
|
|
302
|
+
const [originAndPath, searchParams] = locationUrl.split("?");
|
|
303
|
+
const searchHandled = searchParams ? `?${searchParams.replace(
|
|
304
|
+
encodeURIComponent(fromBasePart),
|
|
305
|
+
encodeURIComponent(gotoBasePart)
|
|
306
|
+
)}` : "";
|
|
307
|
+
const redirectUrl = `${originAndPath}${searchHandled}`;
|
|
293
308
|
const redirectMessage = `[@umijs/plugin-qiankun]: redirect to ${redirectUrl}`;
|
|
294
309
|
api.logger.info(redirectMessage);
|
|
295
310
|
res2.statusCode = 302;
|
package/dist/utils/modelUtils.js
CHANGED
|
@@ -34,6 +34,7 @@ __export(modelUtils_exports, {
|
|
|
34
34
|
getNamespace: () => getNamespace
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(modelUtils_exports);
|
|
37
|
+
var import_bundler_utils = require("@umijs/bundler-utils");
|
|
37
38
|
var parser = __toESM(require("@umijs/bundler-utils/compiled/babel/parser"));
|
|
38
39
|
var import_traverse = __toESM(require("@umijs/bundler-utils/compiled/babel/traverse"));
|
|
39
40
|
var t = __toESM(require("@umijs/bundler-utils/compiled/babel/types"));
|
|
@@ -157,16 +158,28 @@ var _ModelUtils = class {
|
|
|
157
158
|
});
|
|
158
159
|
}
|
|
159
160
|
isModelValid(opts) {
|
|
161
|
+
var _a;
|
|
160
162
|
const { file, content } = opts;
|
|
161
163
|
if (this.opts.contentTest && this.opts.contentTest(content)) {
|
|
162
164
|
return true;
|
|
163
165
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
let result = null;
|
|
167
|
+
try {
|
|
168
|
+
const ext = (0, import_path.extname)(file).slice(1);
|
|
169
|
+
const loader = ext === "js" ? "jsx" : ext;
|
|
170
|
+
result = (0, import_esbuild.transformSync)(content, {
|
|
171
|
+
loader,
|
|
172
|
+
sourcemap: false,
|
|
173
|
+
minify: false,
|
|
174
|
+
sourcefile: file
|
|
175
|
+
});
|
|
176
|
+
} catch (e) {
|
|
177
|
+
if ((_a = e.errors) == null ? void 0 : _a.length) {
|
|
178
|
+
(0, import_bundler_utils.prettyPrintEsBuildErrors)(e.errors, { path: file, content });
|
|
179
|
+
delete e.errors;
|
|
180
|
+
}
|
|
181
|
+
throw e;
|
|
182
|
+
}
|
|
170
183
|
let ret = false;
|
|
171
184
|
const ast = parser.parse(result.code, {
|
|
172
185
|
sourceType: "module",
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
__USE_MODEL__;
|
|
4
4
|
import concat from 'lodash/concat';
|
|
5
5
|
import mergeWith from 'lodash/mergeWith';
|
|
6
|
+
import isEqual from 'lodash/isEqual';
|
|
6
7
|
import noop from 'lodash/noop';
|
|
7
8
|
import {
|
|
8
9
|
FrameworkConfiguration,
|
|
@@ -58,24 +59,21 @@ export type Props = {
|
|
|
58
59
|
className?: string;
|
|
59
60
|
} & Record<string, any>;
|
|
60
61
|
|
|
61
|
-
function unmountMicroApp(microApp?: MicroAppType
|
|
62
|
+
function unmountMicroApp(microApp?: MicroAppType) {
|
|
62
63
|
if (microApp) {
|
|
63
|
-
microApp.mountPromise.then(() =>
|
|
64
|
-
switch (microApp.getStatus()) {
|
|
65
|
-
case "MOUNTED":
|
|
66
|
-
microApp.unmount();
|
|
67
|
-
break;
|
|
68
|
-
case "UPDATING":
|
|
69
|
-
// UPDATING 阶段 updatingPromise 一定存在
|
|
70
|
-
updatingPromise!.then(() => microApp.unmount());
|
|
71
|
-
break;
|
|
72
|
-
default:
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
});
|
|
64
|
+
microApp.mountPromise.then(() => microApp.unmount());
|
|
76
65
|
}
|
|
77
66
|
}
|
|
78
67
|
|
|
68
|
+
function useDeepCompare<T>(value: T): T {
|
|
69
|
+
const ref = useRef<T>(value);
|
|
70
|
+
if (!isEqual(value, ref.current)) {
|
|
71
|
+
ref.current = value;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return ref.current;
|
|
75
|
+
}
|
|
76
|
+
|
|
79
77
|
let noneMounted = true;
|
|
80
78
|
|
|
81
79
|
export const MicroApp = forwardRef(
|
|
@@ -278,7 +276,7 @@ export const MicroApp = forwardRef(
|
|
|
278
276
|
}
|
|
279
277
|
|
|
280
278
|
return noop;
|
|
281
|
-
},
|
|
279
|
+
}, [useDeepCompare({ ...stateForSlave, ...propsFromParams })]);
|
|
282
280
|
|
|
283
281
|
// 未配置自定义 loader 且开启了 autoSetLoading 场景下,使用插件默认的 loader,否则使用自定义 loader
|
|
284
282
|
const microAppLoader =
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/plugins",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.66",
|
|
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",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"files": [
|
|
15
15
|
"dist",
|
|
16
16
|
"libs",
|
|
17
|
-
"
|
|
17
|
+
"templates"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@ahooksjs/use-request": "^2.0.0",
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"styled-components": "6.0.0-beta.9",
|
|
43
43
|
"tslib": "^2",
|
|
44
44
|
"warning": "^4.0.3",
|
|
45
|
-
"@umijs/bundler-utils": "4.0.
|
|
45
|
+
"@umijs/bundler-utils": "4.0.66",
|
|
46
46
|
"@umijs/valtio": "1.0.3"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"antd": "^4.24.1",
|
|
50
|
-
"umi": "4.0.
|
|
50
|
+
"umi": "4.0.66"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|
|
@@ -13,30 +13,32 @@ import {
|
|
|
13
13
|
import { ApplyPluginsType } from 'umi';
|
|
14
14
|
import { getPluginManager } from '../core/plugin';
|
|
15
15
|
|
|
16
|
+
let cacheAntdConfig = null;
|
|
17
|
+
|
|
18
|
+
const getAntdConfig = () => {
|
|
19
|
+
if(!cacheAntdConfig){
|
|
20
|
+
cacheAntdConfig = getPluginManager().applyPlugins({
|
|
21
|
+
key: 'antd',
|
|
22
|
+
type: ApplyPluginsType.modify,
|
|
23
|
+
initialValue: {
|
|
24
|
+
{{#configProvider}}
|
|
25
|
+
...{{{configProvider}}},
|
|
26
|
+
{{/configProvider}}
|
|
27
|
+
{{#appConfig}}
|
|
28
|
+
appConfig: {{{appConfig}}},
|
|
29
|
+
{{/appConfig}}
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return cacheAntdConfig;
|
|
34
|
+
}
|
|
35
|
+
|
|
16
36
|
export function rootContainer(rawContainer) {
|
|
17
37
|
const {
|
|
18
|
-
appConfig
|
|
38
|
+
appConfig,
|
|
19
39
|
...finalConfigProvider
|
|
20
|
-
} =
|
|
21
|
-
key: 'antd',
|
|
22
|
-
type: ApplyPluginsType.modify,
|
|
23
|
-
initialValue: {
|
|
24
|
-
{{#configProvider}}
|
|
25
|
-
...{{{configProvider}}},
|
|
26
|
-
{{/configProvider}}
|
|
27
|
-
{{#appConfig}}
|
|
28
|
-
appConfig: {{{appConfig}}},
|
|
29
|
-
{{/appConfig}}
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
|
|
40
|
+
} = getAntdConfig();
|
|
33
41
|
let container = rawContainer;
|
|
34
|
-
|
|
35
|
-
{{#appConfig}}
|
|
36
|
-
// The App component should be under ConfigProvider
|
|
37
|
-
container = <App {...finalAppConfig}>{container}</App>;
|
|
38
|
-
{{/appConfig}}
|
|
39
|
-
|
|
40
42
|
{{#configProvider}}
|
|
41
43
|
if (finalConfigProvider.prefixCls) {
|
|
42
44
|
Modal.config({
|
|
@@ -61,3 +63,14 @@ export function rootContainer(rawContainer) {
|
|
|
61
63
|
|
|
62
64
|
return container;
|
|
63
65
|
}
|
|
66
|
+
|
|
67
|
+
{{#appConfig}}
|
|
68
|
+
// The App component should be under ConfigProvider
|
|
69
|
+
// plugin-locale has other ConfigProvider
|
|
70
|
+
export function innerProvider(container: any) {
|
|
71
|
+
const {
|
|
72
|
+
appConfig: finalAppConfig = {},
|
|
73
|
+
} = getAntdConfig();
|
|
74
|
+
return <App {...finalAppConfig}>{container}</App>;
|
|
75
|
+
}
|
|
76
|
+
{{/appConfig}}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|