Support module loading priority #16523
Labels
enhancement
New feature or request
p2-nice-to-have
Not breaking anything but nice to have (priority)
performance
Performance related enhancement
Description
Here are two use cases:
Assume there are some time-consuming modules. Firstly we load the app's framework (including a loading animation), and then the app dynamically imports the time-consuming modules, so that users can watch the loading animation while waiting.
The problem is that if the user opens the browser page moments later after the server starts, it would be better if the time-consuming modules could be warmed up during this time. But if we set the
warnup
option to those modules, the loading & transformation of them will start eagerly, which blocks the app framework (which should be of higher priority) from loading.Currently, only modules that are intended to load synchronously can take advantage of
warmup
because of the above problem.Take Slidev as an example: There are many slides in a Slidev app, and each slide as a module takes a long time to load. If we load all of them in parallel, users have to wait for a long time for the slides, including the slide they are watching. The ideal way to load these modules is to load them one by one, which means the closer the slide is to the active slide, the higher priority it will be of.
Suggested solution
I don't know.
Alternative
For the second use case, there are some complex ways to make it, such as setting a timeout after one slide is loaded to load the next slide. But this can't make use of Vite's parallel loading feature and doesn't have the best performance.
Additional context
I am wondering if this use case is really common. Because Vite is designed as a dev server, but Slidev uses Vite as the backend 😂. I am also wondering if Vitest will also benefit from this feature.
Validations
The text was updated successfully, but these errors were encountered: