Skip to content

fix: handle array-returning Vite plugins in mergeConfigDedup#89

Merged
pffigueiredo merged 5 commits intomainfrom
fix/merge-config-dedup-array-plugins
Feb 26, 2026
Merged

fix: handle array-returning Vite plugins in mergeConfigDedup#89
pffigueiredo merged 5 commits intomainfrom
fix/merge-config-dedup-array-plugins

Conversation

@pffigueiredo
Copy link
Copy Markdown
Contributor

@pffigueiredo pffigueiredo commented Feb 6, 2026

Description

mergeConfigDedup assumed every entry in the plugins array is a single Plugin object with a .name property. However, Vite's PluginOption type allows plugins to be arrays (nested), falsy values, or promises. Plugins like @tailwindcss/vite return Plugin[] — a standard Vite convention called "plugin presets." This caused mergeConfigDedup to fail because it accessed .name on an array.

FIXES

  • Flatten nested plugin arrays recursively before deduplication (handles @tailwindcss/vite and similar)
  • Filter out falsy values (false, null, undefined) — standard Vite convention for conditional plugins
  • Deduplication by .name works correctly for all plugin types

Test Plan

Added unit tests in packages/appkit/src/utils/tests/vite-config-merge.test.ts covering:

  • Deduplication of single plugins by name
  • Flattening array-returning plugins
  • Deduplication across flattened array plugins and single plugins
  • Deeply nested plugin arrays
  • Filtering out falsy plugin entries
  • Mixed falsy and valid plugins

Manual Testing

  • Built and used the local version of appkit to make sure this fixed the issue

pffigueiredo and others added 3 commits February 6, 2026 14:35
Flatten nested arrays and filter falsy values before deduplicating,
matching Vite's own PluginOption handling. Fixes crash with plugins
like @tailwindcss/vite that return Plugin[].

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Pedro Figueiredo <klisarkk@gmail.com>
@pffigueiredo pffigueiredo self-assigned this Feb 6, 2026
@pkosiec
Copy link
Copy Markdown
Member

pkosiec commented Feb 10, 2026

@MarioCadenas please take a look, as I'm not sure if this doesn't conflict with your changes in the plugins area?

Copy link
Copy Markdown
Member

@pkosiec pkosiec left a comment

Choose a reason for hiding this comment

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

LGTM - but please resolve the comment before the merge. Thank you!

Comment thread .gitignore Outdated
.turbo

# AI generated plans from developer loop
docs/plans No newline at end of file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

let's remove this - it might be confusing as our docs directory contain actually docs. AFAIK the path is configurable for claude code, so IMO it's better to use ./tmp maybe?

@pffigueiredo pffigueiredo merged commit a9c3c1d into main Feb 26, 2026
6 checks passed
@pffigueiredo pffigueiredo deleted the fix/merge-config-dedup-array-plugins branch February 26, 2026 16:52
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.

3 participants