@umijs/plugins 4.0.63 → 4.0.64

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/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));
@@ -58,9 +58,21 @@ export type Props = {
58
58
  className?: string;
59
59
  } & Record<string, any>;
60
60
 
61
- function unmountMicroApp(microApp?: MicroAppType) {
61
+ function unmountMicroApp(microApp?: MicroAppType, updatingPromise?: Promise<void>) {
62
62
  if (microApp) {
63
- microApp.mountPromise.then(() => microApp.unmount());
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
76
  }
65
77
  }
66
78
 
@@ -213,7 +225,7 @@ export const MicroApp = forwardRef(
213
225
  },
214
226
  );
215
227
 
216
- return () => unmountMicroApp(microAppRef.current);
228
+ return () => unmountMicroApp(microAppRef.current, updatingPromise.current);
217
229
  }, [name]);
218
230
 
219
231
  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.64",
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.64",
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.64"
51
51
  },
52
52
  "publishConfig": {
53
53
  "access": "public"