fix: suppress addWatchFile invalid phase error #14751
Merged
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.
Description
Fix https://github.com/vitejs/vite/actions/runs/6624843925/job/17994626864?pr=11151
The error happens at
watchFile
vite/packages/vite/src/node/packages.ts
Lines 233 to 236 in 14966a9
While we do swap to a stub after the build ends at
vite/packages/vite/src/node/packages.ts
Lines 248 to 250 in 14966a9
Rollup only calls
buildEnd
here https://github.com/rollup/rollup/blob/de1c7b6b30f44047026922c168d3a876fdd5514f/src/rollup/rollup.ts#L83, but the "generate phase" (that's used to track and trigger the error) is set at https://github.com/rollup/rollup/blob/de1c7b6b30f44047026922c168d3a876fdd5514f/src/Graph.ts#L120 (insidegraph.build()
, which is called in the code above the first Rollup link. Additionally, here'saddWatchFIle
's error guard https://github.com/rollup/rollup/blob/de1c7b6b30f44047026922c168d3a876fdd5514f/src/utils/PluginContext.ts#L56-L61So there's a short in-between phase where Rollup declares the start of "generate phase" but haven't ended the build with
buildEnd
yet. This PR suppresses the error for now as there's no way to detect the phase.Additional context
What is the purpose of this pull request?