-
-
Notifications
You must be signed in to change notification settings - Fork 122
Description
Describe the problem
Components are compiled twice for ssr.
- with
generate: "ssr"for the serverside render - with
generate: "dom"for the clientside bundle
The current implementation runs preprocess for each step separately which is wastful, especially for more demanding preprocessors like postcss or mdsvex.
Also components that are never compiled for ssr still get compiled with hydratable: true. Even though they are clientside only.
Describe the proposed solution
To avoid duplicate preprocessing, compile both variants in parallel during transform with ssr: true and cache + reuse the compiled dom variant in subsequent transform with ssr: false
Only set hydratable: true in this parallel compilation, components that are only transformed with ssr: false can be compiled with hydratable: false to reduce output size.
Possible issue:
the special svelte/ssr resolve mechanism could break the dom output if it was compiled during the transform with ssr: true
If that is indeed the case, the preprocess result could be cached instead and used as an indicator that the client variant needs to be compiled with hydratable: true
Alternatives considered
stick with the current implementation. This plugin has had issues with aggressive caching for ssr before and caching was completely removed to avoid it.
Importance
nice to have