mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #1014] [MERGED] fix(dev): avoid app reloads for colocated files #1016
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#1016
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/1014
Author: @NathanDrake2406
Created: 5/2/2026
Status: ✅ Merged
Merged: 5/2/2026
Merged by: @james-elicx
Base:
main← Head:nathan/app-watcher-route-files📝 Commits (1)
1d72b85fix(dev): avoid app reloads for colocated files📊 Changes
4 files changed (+149 additions, -10 deletions)
View changed files
📝
packages/vinext/src/index.ts(+12 -9)➕
packages/vinext/src/server/dev-route-files.ts(+94 -0)📝
packages/vinext/src/server/metadata-routes.ts(+1 -1)📝
tests/file-matcher.test.ts(+42 -0)📄 Description
What this changes
Stops the App Router dev watcher from invalidating the generated route entry and sending a full reload when ordinary colocated files are added or removed under
app/, such asapp/components/Button.tsx.The watcher now invalidates only files that can affect App Router structure or generated metadata route entries: route conventions such as
page,route,layout,template,loading,error, access fallback files, rootglobal-error, and vinext metadata route files.Fixes #1013.
Why
Next.js explicitly treats arbitrary project files in
app/as safely colocated and non-routable. The source backs that up in the route discovery matcher:createValidFileMatcherbuilds leaf-only app route matchersvinext was using only the broad page extension regex for
app/watcher add/unlink events, so any.ts,.tsx,.js, or.jsxfile underapp/looked route-affecting and triggered a full reload.Approach
Add a small pure predicate,
shouldInvalidateAppRouteFile, that mirrors vinext's current App Router and metadata discovery boundaries:app/directory, fixing sibling-prefix cases likeapp-utils/_foldersThe watcher still keeps the broad extension behavior for the Pages Router, since every matching file under
pages/is routable by design unless filtered elsewhere.Validation
vp test run tests/file-matcher.test.tsvp test run tests/file-matcher.test.ts tests/page-extensions-routing.test.tsvp check tests/file-matcher.test.ts packages/vinext/src/server/dev-route-files.ts packages/vinext/src/index.ts packages/vinext/src/server/metadata-routes.tsvp run vinext#buildThe package build completed successfully with the existing virtual-module externalization warnings for
private-next-instrumentation-client,virtual:vinext-rsc-entry, andvirtual:vite-rsc/client-references.Risks / follow-ups
The metadata side intentionally follows vinext's current
scanMetadataFilesbehavior, not every future Next.js metadata convention. If vinext expands metadata route support later, this predicate should be updated with the same source of truth.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.