fix(next): resolve src/ entry patterns like Next.js does#1859
Merged
webpro merged 1 commit intoJul 5, 2026
Conversation
dayongkr
force-pushed
the
feat/next-conditional-src-patterns
branch
4 times, most recently
from
July 5, 2026 08:50
5b2d17a to
292bfe8
Compare
dayongkr
marked this pull request as ready for review
July 5, 2026 08:59
dayongkr
marked this pull request as draft
July 5, 2026 09:07
dayongkr
force-pushed
the
feat/next-conditional-src-patterns
branch
from
July 5, 2026 09:30
292bfe8 to
20c2319
Compare
dayongkr
force-pushed
the
feat/next-conditional-src-patterns
branch
from
July 5, 2026 09:34
20c2319 to
1cc0062
Compare
dayongkr
marked this pull request as ready for review
July 5, 2026 09:35
commit: |
Member
|
Thank you @dayongkr! ✨ |
Member
|
🚀 This pull request is included in v6.25.0. See Release 6.25.0 for release notes. Using Knip in a commercial project? Please consider becoming a sponsor. |
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.
Problem
The plugin marks files as production entries that Next.js never even picks up, so dead code sits there unreported.
Every entry pattern is added twice, for the root and for
src/, but Next.js only ever uses one of the two locations per router directory — from the src folder docs:Example — a project routes from a root
pages/directory and keeps the page implementations undersrc/pages/:Next.js ignores
src/pageshere, but the plugin'ssrc/pages/**entry pattern marks every file in it as a production entry, soOldPage.tsxis never reported as an unused file.Fix
When
next.config.*is present, locate each router directory the way Next.js does (find-pages-dir.ts, unchanged since v12) and scope theapp/andpages/entry patterns to the resolved location: root when the root directory exists,src/when only the src one does, both when neither is found.pagesandappare located independently, since mixing a rootpages/withsrc/appis valid up to Next.js 15 (the same-parent restriction was added in 16.0).Root-level file conventions (
middleware,proxy,instrumentation,instrumentation-client) are out of scope and stay matched in both locations, as before.Tests
next-root-and-src(new): rootapp/+pages/next to asrc/folder —src/app/page.tsxandsrc/pages/legacy.tsare reported unused; root entries andsrc/middleware.tsare not.next-mixed-routers(new): rootpages/combined withsrc/app— all router files stay entries.