fix: allow nested dependency selector to be used for optimizeDeps.include for SSR#18506
Merged
patak-cat merged 10 commits intovitejs:mainfrom Oct 31, 2024
Merged
Conversation
- `depOptimizer` is `undefined` when `isBuild` is `true` - `options.scan` is always `false` here because its checked in line 861
optimizeDeps.include for SSR
patak-cat
approved these changes
Oct 31, 2024
Member
patak-cat
left a comment
There was a problem hiding this comment.
great to see __vite_skip_optimization deleted ❤️
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
I started this PR as a refactor but turned out that I can fix a bug that will simplify the code more.
The bug is that
optimizeDeps.include: ['foo > bar']was not working only for SSR.ssrOptimizeCheckis set at this line.vite/packages/vite/src/node/optimizer/resolve.ts
Line 18 in 2c10f9a
That makes this condition to be used and
vite/packages/vite/src/node/plugins/resolve.ts
Line 896 in 2c10f9a
because we pass the
absolute/path/to/foo/package.jsonas a importervite/packages/vite/src/node/optimizer/resolve.ts
Line 38 in 2c10f9a
that condition is always
truefor nested selectors.So all dependencies specified with nested selectors in
optimizeDeps.includewill be skipped.The purpose of using
skipOptimizationfor SSR seems to be to only optimize CJS deps (#8932). But this is not the case anymore since #18358 and probably can be removed.Commits in this PR other than 817640e should not change any behavior.