8000 Correct the behavior when multiple transform filter options are specified by sapphi-red · Pull Request #5909 · rollup/rollup · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Correct the behavior when multiple transform filter options are specified #5909

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

Conversation

sapphi-red
Copy link
Contributor

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no (I think this is not a breaking change as the previous behavior does not work well)

List any relevant issue numbers:

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

Copy link
vercel bot commented Apr 9, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
rollup ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 11, 2025 2:27am

Copy link
codecov bot commented Apr 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.56%. Comparing base (328fa2d) to head (3d092e1).
Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5909      +/-   ##
==========================================
- Coverage   98.56%   98.56%   -0.01%     
==========================================
  Files         270      270              
  Lines        8688     8683       -5     
  Branches     1488     1488              
==========================================
- Hits         8563     8558       -5     
  Misses         92       92              
  Partials       33       33              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

sxzz added a commit to unjs/unplugin that referenced this pull request Apr 11, 2025
@lukastaegert lukastaegert added this pull request to the merge queue Apr 12, 2025
Merged via the queue into rollup:master with commit 02a060d Apr 12, 2025
41 checks passed
Copy link

This PR has been released as part of rollup@4.40.0. You can test it via npm install rollup.

@sapphi-red sapphi-red deleted the fix/behavior-multiple-transform-filter-options branch April 12, 2025 10:19
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
0