@umijs/plugins 4.0.67 → 4.0.69

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/layout.js CHANGED
@@ -463,10 +463,25 @@ export function getRightRenderContent (opts: {
463
463
  ],
464
464
  };
465
465
  // antd@5 和 4.24 之后推荐使用 menu,性能更好
466
- const dropdownProps =
467
- version.startsWith("5.") || version.startsWith("4.24.")
468
- ? { menu: langMenu }
469
- : { overlay: <Menu {...langMenu} /> };
466
+ let dropdownProps;
467
+ if (version.startsWith("5.") || version.startsWith("4.24.")) {
468
+ dropdownProps = { menu: langMenu };
469
+ } else if (version.startsWith("3.")) {
470
+ dropdownProps = {
471
+ overlay: (
472
+ <Menu>
473
+ {langMenu.items.map((item) => (
474
+ <Menu.Item key={item.key} onClick={item.onClick}>
475
+ {item.label}
476
+ </Menu.Item>
477
+ ))}
478
+ </Menu>
479
+ ),
480
+ };
481
+ } else { // 需要 antd 4.20.0 以上版本
482
+ dropdownProps = { overlay: <Menu {...langMenu} /> };
483
+ }
484
+
470
485
 
471
486
  return (
472
487
  <div className="umi-plugin-layout-right anticon">
package/dist/mf.js CHANGED
@@ -22,6 +22,7 @@ __export(mf_exports, {
22
22
  default: () => mf
23
23
  });
24
24
  module.exports = __toCommonJS(mf_exports);
25
+ var import_bundler_utils = require("@umijs/bundler-utils");
25
26
  var import_fs = require("fs");
26
27
  var import_path = require("path");
27
28
  var import_plugin_utils = require("umi/plugin-utils");
@@ -66,7 +67,7 @@ function mf(api) {
66
67
  return config;
67
68
  }
68
69
  if (!isEmpty(remotes)) {
69
- if (!api.config.mfsu) {
70
+ if (api.env === "production" || !api.config.mfsu) {
70
71
  changeUmiEntry(config);
71
72
  }
72
73
  }
@@ -125,13 +126,48 @@ function mf(api) {
125
126
  },
126
127
  tplPath: (0, import_plugin_utils.winPath)((0, import_path.join)(MF_TEMPLATES_DIR, "runtime.ts.tpl"))
127
128
  });
128
- if (api.env === "development" && api.config.mfsu) {
129
- return;
129
+ });
130
+ api.register({
131
+ key: "onGenerateFiles",
132
+ // ensure after generate tpm files
133
+ stage: 10001,
134
+ fn: async () => {
135
+ if (api.env === "development" && api.config.mfsu) {
136
+ return;
137
+ }
138
+ const entry = (0, import_path.join)(api.paths.absTmpPath, "umi.ts");
139
+ const content = (0, import_fs.readFileSync)(
140
+ (0, import_path.join)(api.paths.absTmpPath, "umi.ts"),
141
+ "utf-8"
142
+ );
143
+ const [_imports, exports] = await (0, import_bundler_utils.parseModule)({ content, path: entry });
144
+ const mfEntryContent = [];
145
+ let hasDefaultExport = false;
146
+ if (exports.length) {
147
+ mfEntryContent.push(
148
+ `const umiExports = await import('${(0, import_plugin_utils.winPath)(entry)}')`
149
+ );
150
+ for (const exportName of exports) {
151
+ if (exportName === "default") {
152
+ hasDefaultExport = true;
153
+ mfEntryContent.push(`export default umiExports.${exportName}`);
154
+ } else {
155
+ mfEntryContent.push(
156
+ `export const ${exportName} = umiExports.${exportName}`
157
+ );
158
+ }
159
+ }
160
+ } else {
161
+ mfEntryContent.push(`import('${(0, import_plugin_utils.winPath)(entry)}')`);
162
+ }
163
+ if (!hasDefaultExport) {
164
+ mfEntryContent.push("export default 1");
165
+ }
166
+ api.writeTmpFile({
167
+ content: mfEntryContent.join("\n"),
168
+ path: mfAsyncEntryFileName
169
+ });
130
170
  }
131
- api.writeTmpFile({
132
- content: `import('${(0, import_plugin_utils.winPath)((0, import_path.join)(api.paths.absTmpPath, "umi.ts"))}')`,
133
- path: mfAsyncEntryFileName
134
- });
135
171
  });
136
172
  function formatRemotes() {
137
173
  const { remotes = [] } = api.userConfig.mf;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/plugins",
3
- "version": "4.0.67",
3
+ "version": "4.0.69",
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",
@@ -40,15 +40,15 @@
40
40
  "react-intl": "3.12.1",
41
41
  "react-redux": "^8.0.5",
42
42
  "redux": "^4.2.1",
43
- "styled-components": "6.0.0-beta.9",
43
+ "styled-components": "6.0.0-rc.0",
44
44
  "tslib": "^2",
45
45
  "warning": "^4.0.3",
46
- "@umijs/bundler-utils": "4.0.67",
46
+ "@umijs/bundler-utils": "4.0.69",
47
47
  "@umijs/valtio": "1.0.3"
48
48
  },
49
49
  "devDependencies": {
50
50
  "antd": "^4.24.1",
51
- "umi": "4.0.67"
51
+ "umi": "4.0.69"
52
52
  },
53
53
  "publishConfig": {
54
54
  "access": "public"
@@ -442,12 +442,25 @@ export const SelectLang: React.FC<SelectLangProps> = (props) => {
442
442
  };
443
443
 
444
444
  // antd@5 和 4.24 之后推荐使用 menu,性能更好
445
- const dropdownProps =
446
- version.startsWith('5.') || version.startsWith('4.24.')
447
- ? { menu: langMenu }
448
- : { overlay: <Menu {...langMenu} /> };
449
-
450
-
445
+ let dropdownProps;
446
+ if (version.startsWith("5.") || version.startsWith("4.24.")) {
447
+ dropdownProps = { menu: langMenu };
448
+ } else if (version.startsWith("3.")) {
449
+ dropdownProps = {
450
+ overlay: (
451
+ <Menu>
452
+ {langMenu.items.map((item) => (
453
+ <Menu.Item key={item.key} onClick={item.onClick}>
454
+ {item.label}
455
+ </Menu.Item>
456
+ ))}
457
+ </Menu>
458
+ ),
459
+ };
460
+ } else { // 需要 antd 4.20.0 以上版本
461
+ dropdownProps = { overlay: <Menu {...langMenu} /> };
462
+ }
463
+
451
464
  const inlineStyle = {
452
465
  cursor: "pointer",
453
466
  padding: "12px",
@@ -79,7 +79,7 @@ export const addLocale = (
79
79
  messages: Object,
80
80
  extraLocales: {
81
81
  momentLocale:string;
82
- antd:string
82
+ antd: import('antd/es/locale').Locale
83
83
  },
84
84
  ) => {
85
85
  if (!name) {