@umijs/plugins 4.0.0-canary.20230724.1 → 4.0.0-canary.20230811.1

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.
@@ -33,6 +33,7 @@ __export(master_exports, {
33
33
  isMasterEnable: () => isMasterEnable
34
34
  });
35
35
  module.exports = __toCommonJS(master_exports);
36
+ var import_assert = __toESM(require("assert"));
36
37
  var import_fs = require("fs");
37
38
  var import_path = require("path");
38
39
  var import_umi = require("umi");
@@ -47,6 +48,15 @@ function isMasterEnable(opts) {
47
48
  }
48
49
  return !!process.env.INITIAL_QIANKUN_MASTER_OPTIONS;
49
50
  }
51
+ function getCustomLoader(api) {
52
+ var _a, _b, _c;
53
+ const loader = (_b = (_a = api.config.qiankun) == null ? void 0 : _a.master) == null ? void 0 : _b.loader;
54
+ (0, import_assert.default)(
55
+ !loader || ((_c = loader.startsWith) == null ? void 0 : _c.call(loader, "@/")),
56
+ "[@umijs/plugin-qiankun]: loader only support root path, eg: @/loading"
57
+ );
58
+ return loader;
59
+ }
50
60
  var master_default = (api) => {
51
61
  api.describe({
52
62
  key: "qiankun-master",
@@ -134,8 +144,13 @@ export const setMasterOptions = (newOpts) => options = ({ ...options, ...newOpts
134
144
  });
135
145
  api.writeTmpFile({
136
146
  path: "MicroAppLoader.tsx",
137
- // 开启了 antd 插件的时候,使用 antd 的 loader 组件,否则提示用户必须设置一个自定义的 loader 组件
138
- content: api.isPluginEnable("antd") ? getFileContent("AntdLoader.tsx") : `export default function Loader() { console.warn(\`[plugins/qiankun]: Seems like you'r not using @umijs/plugin-antd, you need to provide a custom loader or set autoSetLoading false to shut down this warning!\`); return null; }`
147
+ content: getCustomLoader(api) ? (
148
+ // 用户自定义的 loading 优先级最高
149
+ `export { default } from '${getCustomLoader(api)}';`
150
+ ) : api.isPluginEnable("antd") ? getFileContent("AntdLoader.tsx") : (
151
+ // 开启了 antd 插件的时候,使用 antd 的 loader 组件,否则提示用户必须设置一个自定义的 loader 组件
152
+ `export default function Loader() { console.warn(\`[plugins/qiankun]: Seems like you'r not using @umijs/plugin-antd, you need to provide a custom loader or set autoSetLoading false to shut down this warning!\`); return null; }`
153
+ )
139
154
  });
140
155
  [
141
156
  "common.ts",
@@ -22,8 +22,11 @@ __export(tailwindcss_exports, {
22
22
  default: () => tailwindcss_default
23
23
  });
24
24
  module.exports = __toCommonJS(tailwindcss_exports);
25
+ var import_fs = require("fs");
25
26
  var import_path = require("path");
26
27
  var import_plugin_utils = require("umi/plugin-utils");
28
+ var CHECK_INTERVAL = 300;
29
+ var CHECK_TIMEOUT_UNIT_SECOND = 5;
27
30
  var tailwindcss_default = (api) => {
28
31
  api.describe({
29
32
  key: "tailwindcss",
@@ -71,7 +74,21 @@ var tailwindcss_default = (api) => {
71
74
  });
72
75
  } else {
73
76
  api.logger.info("tailwindcss service started");
74
- resolve();
77
+ const interval = setInterval(() => {
78
+ if ((0, import_fs.existsSync)(generatedPath)) {
79
+ clearInterval(interval);
80
+ resolve();
81
+ }
82
+ }, CHECK_INTERVAL);
83
+ const timer = setTimeout(() => {
84
+ if (!(0, import_fs.existsSync)(generatedPath)) {
85
+ clearInterval(timer);
86
+ api.logger.error(
87
+ `tailwindcss generate failed after ${CHECK_TIMEOUT_UNIT_SECOND} seconds, please check your tailwind.css and tailwind.config.js`
88
+ );
89
+ process.exit(1);
90
+ }
91
+ }, CHECK_TIMEOUT_UNIT_SECOND * 1e3);
75
92
  }
76
93
  });
77
94
  });
@@ -16,9 +16,9 @@ export function getMicroAppRouteComponent(opts: {
16
16
  const match = useMatch(routePath);
17
17
  const url = match ? match.pathnameBase : '';
18
18
  // 默认取静态配置的 base
19
- let umiConfigBase = base === '/' ? '' : base;
19
+ let umiConfigBase = base === '/' ? '' : trimEndSlash(base);
20
20
  // 匹配模式下,routePath 不会作为 prefix
21
- const prefix = routeMode === MicroAppRouteMode.MATCH ? '' : (url.endsWith('/') ? url.substr(0, url.length - 1) : url);
21
+ const prefix = routeMode === MicroAppRouteMode.MATCH ? '' : trimEndSlash(url);
22
22
 
23
23
  // 拼接子应用挂载路由
24
24
  let runtimeMatchedBase = umiConfigBase + prefix;
@@ -39,3 +39,7 @@ export function getMicroAppRouteComponent(opts: {
39
39
 
40
40
  return RouteComponent;
41
41
  }
42
+
43
+ function trimEndSlash(p: string) {
44
+ return p.endsWith('/') ? p.slice(0, -1) : p;
45
+ }
@@ -24,6 +24,7 @@ export type MicroAppRoute = {
24
24
 
25
25
  export type MasterOptions = {
26
26
  enable?: boolean;
27
+ loader?: string;
27
28
  apps?: App[];
28
29
  routes?: MicroAppRoute[];
29
30
  lifeCycles?: FrameworkLifeCycles<object>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/plugins",
3
- "version": "4.0.0-canary.20230724.1",
3
+ "version": "4.0.0-canary.20230811.1",
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",
@@ -44,12 +44,12 @@
44
44
  "styled-components": "6.0.0-rc.0",
45
45
  "tslib": "^2",
46
46
  "warning": "^4.0.3",
47
- "@umijs/bundler-utils": "4.0.0-canary.20230724.1",
48
- "@umijs/valtio": "1.0.3"
47
+ "@umijs/valtio": "1.0.3",
48
+ "@umijs/bundler-utils": "4.0.0-canary.20230811.1"
49
49
  },
50
50
  "devDependencies": {
51
51
  "antd": "^4.24.1",
52
- "umi": "4.0.0-canary.20230724.1"
52
+ "umi": "4.0.0-canary.20230811.1"
53
53
  },
54
54
  "publishConfig": {
55
55
  "access": "public"