feat: ssr build using optimized deps #8403
Merged
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.
Description
Follow up to:
This PR removes the need for
@rollup/plugin-commonjs
for SSR builds, enabling dep optimization using esbuild by default for them.After this PR, if the user doesn't use
optimizeDeps.disabled: 'build'
oroptimizeDeps.devScan: true
then Vite isn't usingplugin-commonjs
or the esbuild scanner. In the same way we are doing with terser, we could decide in Vite v3 to avoid@rollup/plugin-commonjs
as a dependency and ask users to add it to the project themselves if they need it. It isn't a big dep though, so probably not worthy.There is a new deps cache for SSR. We could discuss if the build cache could be reused, but given that most deps will be externalized, I think a separate cache wouldn't affect performance. It will allow users to avoid busting the cache if there is a conditional change for the config depending on if we are building for SSR.
Given that we have more caches now, this PRs renames them to be more future proof:
deps
deps_build
deps_build_ssr
And the prev
processingDeps
are now the same as above but with a_temp
suffix. About using a flat structure instead ofdeps/build
, we discussed in a previous PR with Anthony and Blu that this structure is easier to work with.I thought about renaming
deps
todeps_dev
, but I left it asdeps
because it is shorter and this dir is seen in the browser network tab.@benmccann @brillout I would need some help with testing and validating here. Tests are passing on Vite's side, but maybe we should expand them.
What is the purpose of this pull request?