fix(plugin-vite): register co-located islands added while dev server runs - #3903
Open
limkaa4 wants to merge 1 commit into
Open
fix(plugin-vite): register co-located islands added while dev server runs#3903limkaa4 wants to merge 1 commit into
limkaa4 wants to merge 1 commit into
Conversation
…runs
`isIslandPath()` decides whether a file the watcher reports should join the
client snapshot. Its second branch, the one meant to cover co-located
islands, could never run:
const relIsland = path.relative(options.islandsDir, filePath);
if (!relIsland.startsWith("..")) return true;
...
if (!relIsland.startsWith("..") && relRoutes.includes("(_islands)")) {
Control only reaches the second check when `relIsland` does start with
"..", so the re-test of the same value is always false. A file created in
a `(_islands)` folder was therefore dropped by the watcher, and the island
stayed unregistered until the dev server restarted — while editing an
existing island kept working, which makes it look like flaky HMR rather
than a missing registration.
The layout itself is documented in `concepts/file-routing.md`, and the
initial crawl in `fs_crawl.ts` handles it correctly, so this only affects
files created after the dev server is up.
Test against `relRoutes` instead, and match `(_islands)` as a path segment
rather than a substring, the same way `GROUP_REG` does in `fs_crawl.ts`.
The added tests cover both documented placements: a route group and a
plain route folder.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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
Creating a new island inside a
(_islands)folder while the dev server isrunning does nothing — the island stays unregistered until the server is
restarted. Editing an existing island works fine, so it reads like flaky
HMR rather than a missing registration.
The layout is the documented one from
concepts/file-routing.md:Cause
isIslandPath()inclient_snapshot.tsgates what the watcher feeds intothe client snapshot, and its co-located branch is unreachable:
We only reach the second
ifwhenrelIslanddoes start with"..", sore-testing the same value is always
false.relRoutesis computed andthen never used for the decision.
The initial crawl in
fs_crawl.tshandles these islands correctly, which iswhy a restart fixes it — only files created after startup are affected.
Fix
Test
relRoutes, and match(_islands)as a path segment rather than asubstring, matching
GROUP_REGinfs_crawl.ts. Files outside bothdirectories now bail out early instead of relying on a substring check.
Tests
client_snapshot_test.tscovers the top-levelislands/dir, bothdocumented co-located placements (inside a route group and inside a plain
route folder), and the negative cases —
(_components), a(_islands)xsubstring, and a matching folder outside both directories.
Verified the tests fail against the current implementation and pass with the
fix.
deno fmt,deno lint,deno task check:typesanddeno test -A packages/plugin-vite/src/plugins/are clean.No integration test: the neighbouring dev-server HMR test is already marked
ignore: truefor flakiness, and the regression is fully captured by thepure function.
🤖 Generated with Claude Code