Skip to content

Make --debug-build-paths work with src/ directory projects#94016

Merged
unstubbable merged 1 commit into
canaryfrom
hl/debug-build-paths-src-dir
May 21, 2026
Merged

Make --debug-build-paths work with src/ directory projects#94016
unstubbable merged 1 commit into
canaryfrom
hl/debug-build-paths-src-dir

Conversation

@unstubbable
Copy link
Copy Markdown
Contributor

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.

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.
@unstubbable unstubbable requested a review from mischnic May 21, 2026 10:51
@github-actions
Copy link
Copy Markdown
Contributor

Tests Passed

Commit: 201d801

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`).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@unstubbable unstubbable merged commit 4023e48 into canary May 21, 2026
164 of 165 checks passed
@unstubbable unstubbable deleted the hl/debug-build-paths-src-dir branch May 21, 2026 11:49
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.

2 participants