@umijs/core 4.3.6 → 4.3.7

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/index.js CHANGED
@@ -43,5 +43,9 @@ var import_types = require("./types");
43
43
  IAdd,
44
44
  IEvent,
45
45
  IModify,
46
- IRoute
46
+ IRoute,
47
+ ...require("./config/config"),
48
+ ...require("./route/route"),
49
+ ...require("./service/pluginAPI"),
50
+ ...require("./service/service")
47
51
  });
@@ -19,3 +19,9 @@ module.exports = __toCommonJS(route_exports);
19
19
  __reExport(route_exports, require("./routesConfig"), module.exports);
20
20
  __reExport(route_exports, require("./routesConvention"), module.exports);
21
21
  __reExport(route_exports, require("./routeUtils"), module.exports);
22
+ // Annotate the CommonJS export names for ESM import in node:
23
+ 0 && (module.exports = {
24
+ ...require("./routesConfig"),
25
+ ...require("./routesConvention"),
26
+ ...require("./routeUtils")
27
+ });
@@ -42,10 +42,18 @@ function getConventionRoutes(opts) {
42
42
  }
43
43
  });
44
44
  const routeIds = Object.keys(files).sort(import_utils2.byLongestFirst);
45
+ const parentToChildrenMap = /* @__PURE__ */ new Map();
46
+ routeIds.forEach((id) => {
47
+ const prefix = `${id}/`;
48
+ routeIds.filter((childId) => childId.startsWith(prefix) && childId !== id).forEach((childId) => {
49
+ if (!parentToChildrenMap.has(id)) {
50
+ parentToChildrenMap.set(id, []);
51
+ }
52
+ parentToChildrenMap.get(id).push(childId);
53
+ });
54
+ });
45
55
  function defineNestedRoutes(defineRoute, parentId) {
46
- const childRouteIds = routeIds.filter(
47
- (id) => (0, import_utils2.findParentRouteId)(routeIds, id) === parentId
48
- );
56
+ const childRouteIds = parentId ? parentToChildrenMap.get(parentId) || [] : routeIds;
49
57
  for (let routeId of childRouteIds) {
50
58
  let routePath = createRoutePath(
51
59
  parentId ? routeId.slice(parentId.length + 1) : routeId
@@ -1,7 +1,6 @@
1
1
  export declare function createRouteId(file: string): string;
2
2
  export declare function stripFileExtension(file: string): string;
3
3
  export declare function byLongestFirst(a: string, b: string): number;
4
- export declare function findParentRouteId(routeIds: string[], childRouteId: string): string | undefined;
5
4
  export declare function isRouteModuleFile(opts: {
6
5
  file: string;
7
6
  exclude?: RegExp[];
@@ -21,7 +21,6 @@ var utils_exports = {};
21
21
  __export(utils_exports, {
22
22
  byLongestFirst: () => byLongestFirst,
23
23
  createRouteId: () => createRouteId,
24
- findParentRouteId: () => findParentRouteId,
25
24
  isRouteModuleFile: () => isRouteModuleFile,
26
25
  stripFileExtension: () => stripFileExtension
27
26
  });
@@ -37,9 +36,6 @@ function stripFileExtension(file) {
37
36
  function byLongestFirst(a, b) {
38
37
  return b.length - a.length;
39
38
  }
40
- function findParentRouteId(routeIds, childRouteId) {
41
- return routeIds.find((id) => childRouteId.startsWith(`${id}/`));
42
- }
43
39
  var routeModuleExts = [".js", ".jsx", ".ts", ".tsx", ".md", ".mdx", ".vue"];
44
40
  function isRouteModuleFile(opts) {
45
41
  for (const excludeRegExp of opts.exclude || []) {
@@ -53,7 +49,6 @@ function isRouteModuleFile(opts) {
53
49
  0 && (module.exports = {
54
50
  byLongestFirst,
55
51
  createRouteId,
56
- findParentRouteId,
57
52
  isRouteModuleFile,
58
53
  stripFileExtension
59
54
  });
@@ -100,5 +100,3 @@ umi generate
100
100
  }
101
101
  });
102
102
  };
103
- // Annotate the CommonJS export names for ESM import in node:
104
- 0 && (module.exports = {});
@@ -35,5 +35,3 @@ var servicePlugin_default = (api) => {
35
35
  api.registerMethod({ name });
36
36
  });
37
37
  };
38
- // Annotate the CommonJS export names for ESM import in node:
39
- 0 && (module.exports = {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/core",
3
- "version": "4.3.6",
3
+ "version": "4.3.7",
4
4
  "homepage": "https://github.com/umijs/umi/tree/master/packages/core#readme",
5
5
  "bugs": "https://github.com/umijs/umi/issues",
6
6
  "repository": {
@@ -15,8 +15,8 @@
15
15
  "compiled"
16
16
  ],
17
17
  "dependencies": {
18
- "@umijs/bundler-utils": "4.3.6",
19
- "@umijs/utils": "4.3.6"
18
+ "@umijs/bundler-utils": "4.3.7",
19
+ "@umijs/utils": "4.3.7"
20
20
  },
21
21
  "devDependencies": {
22
22
  "dotenv": "16.0.0",