chore: fix the route.excludes should affect auto-nav-sidebar#2730
chore: fix the route.excludes should affect auto-nav-sidebar#2730
Conversation
❌ Deploy Preview for rspress-v2 failed. Why did it fail? →
|
There was a problem hiding this comment.
Pull Request Overview
This PR adds route validation and exposes the RouteService as a private export, but contains critical bugs that will break the build and runtime functionality.
- Adds validation to check if a route exists in the RouteService before creating RouteMeta
- Adds a new private export path for RouteService in package.json
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/core/src/node/route/RoutePage.ts | Adds route existence validation in absolutePathToRouteMeta function, but creates a circular dependency during initialization |
| packages/core/package.json | Adds new export path for _private/RouteService, but lacks corresponding build configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "./_private/RouteService": { | ||
| "default": "./dist/_private/RouteService/index.js" | ||
| } |
There was a problem hiding this comment.
This export path references ./dist/_private/RouteService/index.js, but there is no corresponding build configuration in rslib.config.ts to generate files in this directory.
The rslib.config.ts has a build entry for _private/react (lines 24-39), but no equivalent entry for _private/RouteService. This means the exported path will not exist after build, causing import failures.
You need to either:
- Add a build configuration entry in
rslib.config.tsto output RouteService files to./dist/_private/RouteService/, or - Remove this export if it's not intended to be exposed as a private API
| "./_private/RouteService": { | |
| "default": "./dist/_private/RouteService/index.js" | |
| } |
| if (!routeService.isExistRoute(routePath)) { | ||
| throw new Error( | ||
| `The routePath "${routePath}" derived from the file "${absolutePath}" does not exist in the route service.`, | ||
| ); | ||
| } |
There was a problem hiding this comment.
The validation check isExistRoute(routePath) will fail during route initialization. When RouteService.#init() calls RoutePage.create() (line 162 in RouteService.ts), this function creates a RouteMeta before the route has been added to routeData. The route is only added after the RoutePage is created (via addRoute() at line 163 in RouteService.ts), creating a chicken-and-egg problem.
This check should either:
- Be moved to a different location where it's called after routes are initialized (e.g., in
absolutePathToRoutePathwhen called from link processing) - Be conditional - only run when routes are already initialized
- Be removed from this function and placed in the callers that need this validation
|
resolved in #3171 |
Summary
chore: fix the route.excludes should affect auto-nav-sidebar
Related Issue
Checklist