Make --debug-build-paths work with src/ directory projects#94016
Merged
Conversation
The `--debug-build-paths` option silently dropped routes in projects that keep their `app` or `pages` directory under `src/`. When a user passed `src/app/foo/page.tsx`, the glob matched the file but `categorizeAndAddPath` only recognized paths starting with `app/` or `pages/`, so nothing was added to the resolved app paths and the build produced no user routes. Conversely, when a user passed the bare `app/foo/page.tsx` form against a `src/app` project, glob found nothing and emitted `did not match any files`. `resolveBuildPaths` now detects whether `src/app` or `src/pages` exists and prepends `src/` to bare patterns before globbing, and `categorizeAndAddPath` strips a leading `src/` from matched files so route keys are normalized either way. Added a `src-dir` fixture and four tests covering explicit `src/` prefixes, bare patterns with auto-prefixing, and glob patterns through route groups.
Contributor
Tests PassedCommit: 201d801 |
mischnic
reviewed
May 21, 2026
Comment on lines
+43
to
+45
| // Detect whether the project keeps its routes under `src/` so we can accept | ||
| // patterns written with or without that prefix (e.g. both `app/foo/page.tsx` | ||
| // and `src/app/foo/page.tsx`). |
Member
There was a problem hiding this comment.
I think we should just say that --debug-build-paths accepts file paths to the page file. If you forget src, then that's on the user
mischnic
approved these changes
May 21, 2026
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.
The
--debug-build-pathsoption silently dropped routes in projects that keep theirapporpagesdirectory undersrc/. When a user passedsrc/app/foo/page.tsx, the glob matched the file butcategorizeAndAddPathonly recognized paths starting withapp/orpages/, so nothing was added to the resolved app paths and the build produced no user routes. Conversely, when a user passed the bareapp/foo/page.tsxform against asrc/appproject, glob found nothing and emitteddid not match any files.resolveBuildPathsnow detects whethersrc/apporsrc/pagesexists and prependssrc/to bare patterns before globbing, andcategorizeAndAddPathstrips a leadingsrc/from matched files so route keys are normalized either way. Added asrc-dirfixture and four tests covering explicitsrc/prefixes, bare patterns with auto-prefixing, and glob patterns through route groups.