Skip to content

Keep route scan order on watcher updates - #28

Open
everton-dgn wants to merge 1 commit into
solidjs:mainfrom
everton-dgn:fix/keep-route-scan-order
Open

everton-dgn wants to merge 1 commit into
solidjs:mainfrom
everton-dgn:fix/keep-route-scan-order

Conversation

@everton-dgn

Copy link
Copy Markdown

Fixes #27

The watcher path changed the manifest order that #14 made deterministic: _addRoute moved an updated route to the end and appended new ones.

  • _addRoute replaces an existing route in place.
  • The router records the source file that first produced each route path. A new route is inserted before the first route whose recorded source sorts after it, which is the position a full scan gives it. removeRoute drops the record.
  • _addRoute takes the source as an optional second argument. Without it, a new route is appended, as before.

This also changes the initial scan when two files map to the same path (for example about.mdx and about.tsx): the entry now keeps the position of the first file instead of moving to the end.

The new tests in test/convention.spec.ts update a route, remove and re-add it, and add files in the middle and at the end, comparing router.routes with a fresh scan after each step; a second test covers two files that map to the same path. Both fail on main.

An updated route was moved to the end of the manifest and new files were appended, so watcher events reordered the manifest and the generated types. Replace existing routes in place and insert new ones where a full scan puts them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Watcher updates move routes out of scan order

1 participant