Skip to content

Conversation

@sapphi-red
Copy link
Member

Description

When multiple filter options were specified for a transform hook, the hook ran when either of it matched.
For example, the following filter matched for modules that whose id is foo or whose code contains a.

{
  filter: { id: ['foo'], code: 'a' }
}

This is not useful.
This PR fixes that behavior. After this PR, the filter above only matches if the module id is foo and the code contains a.
The previous behavior (that is probably rarely needed) can be achieved by using multiple plugins:

const filters = [{ id: ['foo'] }, { code: 'a' }]
const plugins = filters.map(filter => ({ name: 'plugin', transform: { filter, handler() { /* process the module */ } } }))

refs rolldown/rolldown#4059

@sapphi-red sapphi-red added the p3-minor-bug An edge case that only affects very specific usage (priority) label Apr 9, 2025
@sapphi-red sapphi-red added this to the 6.3 milestone Apr 9, 2025
@patak-dev patak-dev merged commit 7200dee into vitejs:main Apr 9, 2025
16 checks passed
@sapphi-red sapphi-red deleted the fix/behavior-for-multiple-filter branch April 9, 2025 10:00
moonlitusun pushed a commit to moonlitusun/vite that referenced this pull request May 25, 2025
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.

2 participants