Skip to content

perf(vite): start warmups after nitro build#27963

Merged
danielroe merged 7 commits intomainfrom
perf/vite-warmup
Jul 2, 2024
Merged

perf(vite): start warmups after nitro build#27963
danielroe merged 7 commits intomainfrom
perf/vite-warmup

Conversation

@danielroe
Copy link
Copy Markdown
Member

🔗 Linked issue

#26211
#27106

📚 Description

Investigating reports of slow startup time for Nuxt, I think there are a couple of ways we can improve things:

  1. use Vite's own warmup mechanism.
  2. ensure we do not block the nitro build with the warmup's heavy fs read operations (it's not a technical block as they run in parallel, but I think in practice it delays it)
Before After
CleanShot 2024-07-02 at 13 51 20@2x CleanShot 2024-07-02 at 13 54 32@2x

We definitely warm up fewer files this way (for example, in the test fixture I'm running, we don't warm up plugin files) and this may be a problem.

I'm also - related to #26211 - trying to track down an issue on Windows machines where vite warmup seems to be non-effective in the server build - even passing entry file to server.warmup doesn't yield transform results for key files. (Maybe a Vite bug - cc: @antfu?)

@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@github-actions github-actions Bot added the bug label Jul 2, 2024
@danielroe danielroe changed the title fix(vite): register nuxt close hook before calling other vite hooks perf(vite): start warmups after nitro build Jul 2, 2024
@antfu
Copy link
Copy Markdown
Member

antfu commented Jul 2, 2024

Looks very nice!

Re: Vite warmup: I have not been using Windows for a long while to tell if it's a Vite bug. I guess it would need a reproduction to make sure it's about vite (or maybe our path normalization?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants