Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow nested dependency selector to be used for optimizeDeps.include for SSR #18506

Merged
merged 10 commits into from
Oct 31, 2024

Conversation

sapphi-red
Copy link
Member

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.
ssrOptimizeCheck is set at this line.

ssrOptimizeCheck: environment.config.consumer === 'server',

That makes this condition to be used and
(importer && isInNodeModules(importer)) ||

because we pass the absolute/path/to/foo/package.json as a importer
path.resolve(basedir, 'package.json'),

that condition is always true for nested selectors.
So all dependencies specified with nested selectors in optimizeDeps.include will be skipped.
The purpose of using skipOptimization for 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.

@sapphi-red sapphi-red added the p3-minor-bug An edge case that only affects very specific usage (priority) label Oct 29, 2024
@sapphi-red sapphi-red changed the title fix: allow nested dependencies to be optimized for SSR fix: allow nested dependency selector to be used for optimizeDeps.include for SSR Oct 29, 2024
Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactor!

Copy link
Member

@patak-dev patak-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great to see __vite_skip_optimization deleted ❤️

@patak-dev patak-dev merged commit 826c81a into vitejs:main Oct 31, 2024
17 checks passed
@sapphi-red sapphi-red deleted the refactor/ssr-optimize-check branch October 31, 2024 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants