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(plugins): noop if config hook returns same config reference #18467

Merged
merged 1 commit into from
Oct 25, 2024

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Oct 25, 2024

Description

If the config() hook returns the same config given, Vite currently merges it again, causing the config to merge onto itself, causing unintended behaviour like resolve.conditions duplicating or other array-based fields.

This PR skips the merge if so to prevent unnecessary work, which in most cases shouldn't be a breaking change. Open to discussion though if we think this is nice to have, or we can ignore it for now.

I found this footgun happening in withastro/astro#12287. And searching around, it seems to happen elsewhere:

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.

Oh... this makes complete sense. Interesting it wasn't discovered before.

@patak-dev patak-dev merged commit bd540d5 into main Oct 25, 2024
14 checks passed
@patak-dev patak-dev deleted the config-return-self branch October 25, 2024 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants