fix: strip the fs-routes root deterministically via a required base option#155
Merged
Conversation
modulesToRouteFiles inferred the routes root as the longest common directory prefix of the import.meta.glob keys. When every page lived under one shared subdirectory (e.g. only ./pages/blog/**), that subdirectory was treated as part of the routes root and stripped, shifting all routes up one level. The plugin now passes its known routes directory (globBase) through to createFsRoutesEntries as a new `base` option, which is stripped deterministically. Direct users of createFsRoutesEntries can pass `base` themselves; the common-prefix heuristic remains as a fallback when base is omitted or does not prefix every key. Closes #139 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EV5Pn6mAHVvqBZHjFKUguA
…rectly Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EV5Pn6mAHVvqBZHjFKUguA
Since base is now always known (the plugin passes its resolved routes directory, and direct users know the directory they globbed), the common-prefix heuristic is removed entirely. A base that does not prefix every globbed key now fails the build with a clear error instead of silently guessing the routes root. The fs-routes module is experimental and not covered by semantic versioning, so this breaking change lands in a minor release. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EV5Pn6mAHVvqBZHjFKUguA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #139
Problem
modulesToRouteFilesinferred the routes root as the longest common directory prefix of theimport.meta.globkeys. When every page happened to live under one shared subdirectory, that subdirectory was treated as part of the routes root and stripped, shifting all routes up one level:{"./pages/blog/page.tsx", "./pages/blog/post/page.tsx"}→ routes/and/postinstead of/blogand/blog/post{"./pages/docs/page.tsx"}→ route/instead of/docsChanges
createFsRoutesEntriesnow takes a requiredbaseoption — the routes directory the glob keys are relative to (e.g."./pages"). The prefix is stripped deterministically; matching is lenient about a trailing slash and a missing./.fsRoutesmode passes its resolved routes directory (globBase) asbasein the generatedvirtual:funstack/entriesmodule, so plugin users are unaffected.basethat does not prefix every globbed key now fails the build with a clear error instead of silently guessing the routes root.basefor directcreateFsRoutesEntriesusers.Requiring
baseis a breaking change for directcreateFsRoutesEntriesusers, but the fs-routes module is experimental and not covered by semantic versioning.Verification
pnpm typecheck,pnpm test:run(81 tests),pnpm lint,pnpm format:check,pnpm buildall pass🤖 Generated with Claude Code
https://claude.ai/code/session_01EV5Pn6mAHVvqBZHjFKUguA
Generated by Claude Code