[2.x] Massive Windows performance improvement of the Vite integration #2021
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.
Abstract
Follow up to #2016, to fix Windows performance with a much faster "hotfile" system like Laravel uses, instead of a slow socket connection test.
Details
This pull request includes changes to improve the performance and functionality of the Vite development server integration. The most important changes include replacing the Vite dev server check with a hot file check and restructuring the Vite configuration to manage the hot file lifecycle.
Improvements to Vite dev server integration:
packages/framework/src/Facades/Vite.php
: Replaced the Vite dev server check with a more efficient hot file check to improve performance, especially on Windows.Restructuring Vite configuration:
vite.config.js
: Introduced a newhydeVitePlugin
to handle the creation and removal of the Vite hot file when the server starts and stops, respectively. This ensures the hot file accurately reflects the server's state. [1] [2]Benchmark (Windows)
Instead of the the ~100ms delay on Windows when running
npm run dev
manually instead of throughphp hyde serve --vite
we now only have a~0.035ms
delay for each page preview.Starting/stopping the Vite server brings a tiny performance impact, which is negligible in this context:
This means the new setup is about 99.965% or ~2857 times faster for individual page previews.