@umijs/core 4.3.5 → 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.
@@ -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
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/core",
3
- "version": "4.3.5",
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/utils": "4.3.5",
19
- "@umijs/bundler-utils": "4.3.5"
18
+ "@umijs/bundler-utils": "4.3.7",
19
+ "@umijs/utils": "4.3.7"
20
20
  },
21
21
  "devDependencies": {
22
22
  "dotenv": "16.0.0",