vite icon indicating copy to clipboard operation
vite copied to clipboard

feat: support warmup by IDs

Open KermanX opened this issue 3 months ago • 2 comments

Description

This PR implements the server.warmup.clientIds and server.warmup.ssrIds options, which are the IDs of modules to be warmed up. For example, ['virtual:custom'].

Slidev's starting time is a little bit too long now, and to improve this, virtual modules like /@slidev/slides/3.md should be warmed up. Currently, Vite's server.warmup.clientFiles only accepts files, and there seem to be no other ways.

I am not 100% sure about the naming conventions in Vite. Should the option be clientIds or clientUrls?

KermanX avatar Apr 18 '24 02:04 KermanX

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

stackblitz[bot] avatar Apr 18 '24 02:04 stackblitz[bot]

I think we should go with url here. It feels a bit too much to have both clientFiles and clientUrls though. I wonder if we could keep only the urls somehow, making the patterns work. So it also better aligns with server.warmupRequest(url)

In Vite 6, we'll have an opportunity to review this API because we are moving it a dev environment config option. Currently it is:

export default defineConfig({
  environments: {
    client: {
      dev: {
        warmup: [files...]
      }
    }
  }
})

So we can directly define that warmup are URLs. Or switch to an object if we need that.

patak-dev avatar Apr 18 '24 09:04 patak-dev