@umijs/plugins 4.0.67 → 4.0.68

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/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.68",
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",
47
- "@umijs/valtio": "1.0.3"
46
+ "@umijs/valtio": "1.0.3",
47
+ "@umijs/bundler-utils": "4.0.68"
48
48
  },
49
49
  "devDependencies": {
50
50
  "antd": "^4.24.1",
51
- "umi": "4.0.67"
51
+ "umi": "4.0.68"
52
52
  },
53
53
  "publishConfig": {
54
54
  "access": "public"
@@ -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) {