fix(deps): watch asset files in linked optimized dependencies - #23401
Open
gilangabdian wants to merge 1 commit into
Open
Conversation
gilangabdian
force-pushed
the
make-asset-file-in-linked-dependencies-can-be-detected-by-watcher
branch
from
August 30, 2026 17:01
f9d7e18 to
7842a5d
Compare
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.
fixes: #14099
What?
This PR fixes a long-standing issue where changing asset files (such as
.css,.html, or.json) inside a linked optimized dependency (e.g., usingnpm linkorpnpm workspace) does not trigger a server reload or HMR.What was changed:
Previously,
optimizer/index.tsonly pushed individual javascriptchunk.moduleIdstometadata.watchFiles. This caused asset files adjacent to those modules to be ignored by thechokidarwatcher.In this PR, we gather the resolved parent directories of optimized dependencies (up to their
package.json) and push these directories intometadata.watchFiles. We also updatedcheckOptimizedDepSourceinserver/index.tsto use.startsWith()instead of strict equality so it can catch any file modifications within those linked directories.watchFilesis also now safely serialized in_metadata.jsonfor cache integrity.Why tests are not included:
An automated test for this was attempted in
playground/optimize-deps. However, editing a linked package's file (e.g.,dep-linked-include/test.css) directly in the source tree violates theplayground-temptest isolation, causing race conditions and flaky failures when running the full test suite in parallel. Thus, this fix is intended to be tested manually or handled via Vite's core E2E suite without explicit git-workspace file mutations.Motivation and Context
Improves DX significantly for monorepo and library developers relying on local symlinks, ensuring that style and asset changes propagate instantly without requiring a manual server restart.
Types of changes