@umijs/plugins 4.0.63 → 4.0.65

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.
@@ -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
- const appName = api.pkg.name;
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"
package/dist/unocss.js CHANGED
@@ -22,7 +22,7 @@ __export(unocss_exports, {
22
22
  default: () => unocss_default
23
23
  });
24
24
  module.exports = __toCommonJS(unocss_exports);
25
- var import_child_process = require("child_process");
25
+ var import_utils = require("@umijs/utils");
26
26
  var import_fs = require("fs");
27
27
  var import_path = require("path");
28
28
  var import_plugin_utils = require("umi/plugin-utils");
@@ -39,7 +39,7 @@ var unocss_default = (api) => {
39
39
  enableBy: api.EnableBy.config
40
40
  });
41
41
  const outputPath = "uno.css";
42
- api.onBeforeCompiler(() => {
42
+ api.onBeforeCompiler(async () => {
43
43
  if (process.env.IS_UMI_BUILD_WORKER)
44
44
  return;
45
45
  if (!(0, import_fs.existsSync)((0, import_path.join)(api.paths.cwd, "unocss.config.ts")))
@@ -48,14 +48,21 @@ var unocss_default = (api) => {
48
48
  );
49
49
  const generatedPath = (0, import_path.join)(api.paths.absTmpPath, outputPath);
50
50
  const binPath = (0, import_path.join)(api.cwd, "node_modules/.bin/unocss");
51
- const watchDirs = api.config.unocss.watch;
52
- const unocss = (0, import_child_process.exec)(
53
- `${binPath} ${watchDirs.join(" ")} --out-file ${generatedPath} ${api.env === "development" ? "--watch" : ""}`,
54
- { cwd: api.cwd }
55
- );
56
- unocss.on("error", (m) => {
57
- api.logger.error("unocss service encounter an error: " + m);
51
+ const watchDirs = api.config.unocss.watch || [];
52
+ const isDev = api.env === "development";
53
+ const args = [
54
+ ...watchDirs,
55
+ "--out-file",
56
+ generatedPath,
57
+ isDev ? "--watch" : ""
58
+ ].filter(Boolean);
59
+ const execaRes = import_utils.execa.execa(binPath, args, {
60
+ cwd: api.cwd,
61
+ stdio: isDev ? "pipe" : "inherit"
58
62
  });
63
+ if (!isDev) {
64
+ await execaRes;
65
+ }
59
66
  });
60
67
  api.addEntryImports(() => {
61
68
  const generatedPath = (0, import_plugin_utils.winPath)((0, import_path.join)(api.paths.absTmpPath, outputPath));
@@ -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
- const loader = (0, import_path.extname)(file).slice(1);
165
- const result = (0, import_esbuild.transformSync)(content, {
166
- loader,
167
- sourcemap: false,
168
- minify: false
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",
@@ -58,9 +58,24 @@ export type Props = {
58
58
  className?: string;
59
59
  } & Record<string, any>;
60
60
 
61
- function unmountMicroApp(microApp?: MicroAppType) {
61
+ function unmountMicroApp(
62
+ microApp?: MicroAppType,
63
+ updatingPromise?: Promise<void>,
64
+ ) {
62
65
  if (microApp) {
63
- microApp.mountPromise.then(() => microApp.unmount());
66
+ microApp.mountPromise.then(() => {
67
+ switch (microApp.getStatus()) {
68
+ case 'MOUNTED':
69
+ microApp.unmount();
70
+ break;
71
+ case 'UPDATING':
72
+ // UPDATING 阶段 updatingPromise 一定存在
73
+ updatingPromise!.then(() => microApp.unmount());
74
+ break;
75
+ default:
76
+ break;
77
+ }
78
+ });
64
79
  }
65
80
  }
66
81
 
@@ -144,7 +159,10 @@ export const MicroApp = forwardRef(
144
159
  const stateForSlave = (useModel || noop)(
145
160
  qiankunStateForSlaveModelNamespace,
146
161
  );
147
- const { entry, props: { settings: settingsFromConfig = {}, ...propsFromConfig } = {} } = appConfig || {};
162
+ const {
163
+ entry,
164
+ props: { settings: settingsFromConfig = {}, ...propsFromConfig } = {},
165
+ } = appConfig || {};
148
166
 
149
167
  useEffect(() => {
150
168
  setComponentError(null);
@@ -213,7 +231,8 @@ export const MicroApp = forwardRef(
213
231
  },
214
232
  );
215
233
 
216
- return () => unmountMicroApp(microAppRef.current);
234
+ return () =>
235
+ unmountMicroApp(microAppRef.current, updatingPromise.current);
217
236
  }, [name]);
218
237
 
219
238
  useEffect(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/plugins",
3
- "version": "4.0.63",
3
+ "version": "4.0.65",
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",
@@ -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.63",
45
+ "@umijs/bundler-utils": "4.0.65",
46
46
  "@umijs/valtio": "1.0.3"
47
47
  },
48
48
  "devDependencies": {
49
49
  "antd": "^4.24.1",
50
- "umi": "4.0.63"
50
+ "umi": "4.0.65"
51
51
  },
52
52
  "publishConfig": {
53
53
  "access": "public"