-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
perf(vite): add plugin hook filter #19308
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
perf(vite): add plugin hook filter #19308
Conversation
WalkthroughPer-serve and per-build async Pre-merge checks✅ Passed checks (3 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/@tailwindcss-vite/src/index.ts(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Linux / upgrade
- GitHub Check: Linux / webpack
- GitHub Check: Linux / cli
- GitHub Check: Linux / postcss
- GitHub Check: Linux / vite
- GitHub Check: Linux
🔇 Additional comments (1)
packages/@tailwindcss-vite/src/index.ts (1)
107-123: LGTM! Handler logic correctly preserves original behavior.The handler implementations maintain the exact same functional behavior as the previous transform functions. The retention of the
isPotentialCssRootFilecheck provides a safety net and ensures backwards compatibility if the filter is not supported by older Vite versions.Also applies to: 140-165
| transform: { | ||
| filter: { | ||
| id: { | ||
| exclude: [/\/\.vite\//, SPECIAL_QUERY_RE, COMMON_JS_PROXY_RE], | ||
| include: [/css(?:\?.*)?$/, /&lang\.css/, INLINE_STYLE_ID_RE], | ||
| }, | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Verify Vite version compatibility for the filter syntax.
The new filter object syntax is a Vite-specific feature. Ensure that the minimum supported Vite version in the package dependencies supports this transform-with-filter-and-handler pattern.
Run the following script to check the Vite version requirements:
🏁 Script executed:
#!/bin/bash
# Check minimum Vite version specified in package.json
# Find and display Vite peer dependencies or dependencies
cat package.json | jq '.peerDependencies.vite // .dependencies.vite // .devDependencies.vite'Length of output: 4
[/run_scripts]
🏁 Script executed:
#!/bin/bash
# Find and display the @tailwindcss-vite package.json with Vite dependency
find . -path "*/packages/@tailwindcss-vite/package.json" -type f | head -1 | xargs cat 2>/dev/null || echo "File not found"Length of output: 1007
[/web_search]
🌐 Web query:
Vite transform filter property not supported older version error
💡 Result:
I need a bit more info to diagnose. Please provide:
- Exact error text and stack trace.
- Your Vite version (from package.json or npm list vite).
- The plugin code (or the transform hook where you set a filter property).
- A minimal repro or repository link, if possible.
Meanwhile try these quick checks:
- If your plugin uses a "filter" property on the transform hook (e.g. transform.filter = /.../), remove it and instead use a manual ID check inside transform or use createFilter from @rollup/pluginutils:
- const filter = createFilter(include, exclude)
- if (!filter(id)) return
- Upgrade Vite to a current version (npm i -D vite@latest) — older Vite/Rollup plugin API compatibility may lack newer plugin features.
- If you’re adapting a Rollup plugin, ensure you follow Vite’s plugin API (transform hook signature: async transform(code, id) { ... }).
- Share the failing plugin code snippet if you want a precise fix.
Provide the requested details and I’ll give an exact fix.
[/web_search]
🌐 Web query:
Vite 6.3.0 release notes transform filter changelog
💡 Result:
Summary: The Vite changelog shows that "hook filters" (transform/filter for plugin hooks) were implemented as a feature in the 6.3.0 beta series and appear in the 6.3.x changelog. The key entry is "feat: implement hook filters (#19602)" in the 6.3.0-beta.0 notes; v6.3.0 stable was released 2025-04-16. [1][2]
Sources
- Changelog excerpt showing 6.3.0 entries including the beta feature "implement hook filters" and v6.3.0 release date. [1]
- Vite Releases page / announcement (Vite 6 stable). [2]
Update peerDependencies to enforce Vite 6.3.0+ minimum.
The transform filter syntax used at lines 100-106 requires Vite 6.3.0 or later. The current peerDependencies allows Vite 5.x and Vite 6.0-6.2, which do not support the filter property. This will cause the transform hook to fail silently or error in incompatible versions.
Update packages/@tailwindcss-vite/package.json:
"peerDependencies": {
"vite": "^6.3.0 || ^7"
}🤖 Prompt for AI Agents
In packages/@tailwindcss-vite/src/index.ts around lines 100 to 106, the
transform.filter usage requires Vite 6.3.0+; open
packages/@tailwindcss-vite/package.json and update the peerDependencies entry
for vite to "vite": "^6.3.0 || ^7" (or equivalent semver expression) then run
dependency install/update to refresh lockfile/CI so the new peer requirement is
enforced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai The syntax is backwards-compatible as the original check is still included in the handler function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!
|
Ah, good call! Should probably add a test for Left one comment for you |
Co-authored-by: Jordan Pittman <[email protected]>
|
Probably will end up doing a release next week at some point if I can get a couple of bug fixes into core. Will be testable via our insiders build in like 20m or so: |
Here is everything you need to know about this update. Please take a good look at what changed and the test results before merging this pull request. ### What changed? #### ✳️ eslint (9.18.0 → 9.19.0) · [Repo](https://github.com/eslint/eslint) · [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) <details> <summary>Release Notes</summary> <h4><a href="https://github.com/eslint/eslint/releases/tag/v9.19.0">9.19.0</a></h4> <blockquote><h2 dir="auto">Features</h2> <ul dir="auto"> <li> <a href="https://bounce.depfu.com/github.com/eslint/eslint/commit/1637b8e87df5c7f58ab71e0e159f4b96c998e070"><code class="notranslate">1637b8e</code></a> feat: add <code class="notranslate">--report-unused-inline-configs</code> (<a href="https://bounce.depfu.com/github.com/eslint/eslint/pull/19201">#19201</a>) (Josh Goldberg ✨)</li> </ul> <h2 dir="auto">Bug Fixes</h2> <ul dir="auto"> <li> <a href="https://bounce.depfu.com/github.com/eslint/eslint/commit/aae67172ab9631b4267fc03f64d3c3d6d1fcda73"><code class="notranslate">aae6717</code></a> fix: sync rule type header comments automatically (<a href="https://bounce.depfu.com/github.com/eslint/eslint/pull/19276">#19276</a>) (Francesco Trotta)</li> </ul> <h2 dir="auto">Documentation</h2> <ul dir="auto"> <li> <a href="https://bounce.depfu.com/github.com/eslint/eslint/commit/cfea9abe0e27cf2ce1d27232b8c70555397e141b"><code class="notranslate">cfea9ab</code></a> docs: Clarify overrideConfig option (<a href="https://bounce.depfu.com/github.com/eslint/eslint/pull/19370">#19370</a>) (Nicholas C. Zakas)</li> <li> <a href="https://bounce.depfu.com/github.com/eslint/eslint/commit/2b84f666cd7474bb061e2f12205af57f5dbb89d6"><code class="notranslate">2b84f66</code></a> docs: Update README (<a href="https://bounce.depfu.com/github.com/eslint/eslint/pull/19362">#19362</a>) (Nicholas C. Zakas)</li> <li> <a href="https://bounce.depfu.com/github.com/eslint/eslint/commit/044f93cbbe71a45130156004509083814e2b9669"><code class="notranslate">044f93c</code></a> docs: clarify frozen rule description (<a href="https://bounce.depfu.com/github.com/eslint/eslint/pull/19351">#19351</a>) (Pavel)</li> <li> <a href="https://bounce.depfu.com/github.com/eslint/eslint/commit/797ee7c0d669678b90c5d5742228bc7b24353f79"><code class="notranslate">797ee7c</code></a> docs: fix Bluesky links (<a href="https://bounce.depfu.com/github.com/eslint/eslint/pull/19368">#19368</a>) (Milos Djermanovic)</li> <li> <a href="https://bounce.depfu.com/github.com/eslint/eslint/commit/81a9c0ebc33dd33765711296f827c4448c80163d"><code class="notranslate">81a9c0e</code></a> docs: Update README (GitHub Actions Bot)</li> <li> <a href="https://bounce.depfu.com/github.com/eslint/eslint/commit/093fb3d40286588c2c425b738426ebfe5d142a63"><code class="notranslate">093fb3d</code></a> docs: replace <code class="notranslate">var</code> with <code class="notranslate">let</code> and <code class="notranslate">const</code> in rule examples (<a href="https://bounce.depfu.com/github.com/eslint/eslint/pull/19365">#19365</a>) (Tanuj Kanti)</li> <li> <a href="https://bounce.depfu.com/github.com/eslint/eslint/commit/417de3298527e4f257e1ae7b02e1df9db3c9ed33"><code class="notranslate">417de32</code></a> docs: replace var with const in rule examples (<a href="https://bounce.depfu.com/github.com/eslint/eslint/pull/19352">#19352</a>) (jj)</li> <li> <a href="https://bounce.depfu.com/github.com/eslint/eslint/commit/17f2aaec16d5afbb0d219bce6ae01d7b15d74828"><code class="notranslate">17f2aae</code></a> docs: update getting-started config to match default generated config (<a href="https://bounce.depfu.com/github.com/eslint/eslint/pull/19308">#19308</a>) (0xDev)</li> <li> <a href="https://bounce.depfu.com/github.com/eslint/eslint/commit/8a0a5a8851f72982327c2aa3a41403963f025771"><code class="notranslate">8a0a5a8</code></a> docs: better <code class="notranslate">global ignores</code> instruction (<a href="https://bounce.depfu.com/github.com/eslint/eslint/pull/19297">#19297</a>) (Jacopo Marrone)</li> <li> <a href="https://bounce.depfu.com/github.com/eslint/eslint/commit/6671a2cd8ccc710fefbccad9a813c3bea5f76c68"><code class="notranslate">6671a2c</code></a> docs: Update README (GitHub Actions Bot)</li> <li> <a href="https://bounce.depfu.com/github.com/eslint/eslint/commit/e39d3f22ff793db42e1f1fc3808cbb12fc513118"><code class="notranslate">e39d3f2</code></a> docs: fix divider for rule category (<a href="https://bounce.depfu.com/github.com/eslint/eslint/pull/19264">#19264</a>) (Tanuj Kanti)</li> <li> <a href="https://bounce.depfu.com/github.com/eslint/eslint/commit/e0cf53f80a4b127524e0badc8999d5d1a247143f"><code class="notranslate">e0cf53f</code></a> docs: fix search result box position for small screens (<a href="https://bounce.depfu.com/github.com/eslint/eslint/pull/19328">#19328</a>) (Tanuj Kanti)</li> <li> <a href="https://bounce.depfu.com/github.com/eslint/eslint/commit/f92a6803a10c66cf77408b2bf29c17bcd63b1049"><code class="notranslate">f92a680</code></a> docs: replace var with let or const in rule examples (<a href="https://bounce.depfu.com/github.com/eslint/eslint/pull/19331">#19331</a>) (Ravi Teja Kolla)</li> <li> <a href="https://bounce.depfu.com/github.com/eslint/eslint/commit/b04b84bc17d4aaaea1326cb08196593624db02a2"><code class="notranslate">b04b84b</code></a> docs: revert accidental changes in TS config files docs (<a href="https://bounce.depfu.com/github.com/eslint/eslint/pull/19336">#19336</a>) (Francesco Trotta)</li> </ul> <h2 dir="auto">Chores</h2> <ul dir="auto"> <li> <a href="https://bounce.depfu.com/github.com/eslint/eslint/commit/9b9cb0584867916d50aa2e9590b132e2ef8ca59c"><code class="notranslate">9b9cb05</code></a> chore: upgrade @eslint/[email protected] (<a href="https://bounce.depfu.com/github.com/eslint/eslint/pull/19371">#19371</a>) (Milos Djermanovic)</li> <li> <a href="https://bounce.depfu.com/github.com/eslint/eslint/commit/58560e70bb4dcb305343fcd7c893ac56a404f674"><code class="notranslate">58560e7</code></a> chore: package.json update for @eslint/js release (Jenkins)</li> <li> <a href="https://bounce.depfu.com/github.com/eslint/eslint/commit/20897070913418078d8f1ea9a877d223650dff73"><code class="notranslate">2089707</code></a> test: fix failing test in Node.js v22.13.0 (<a href="https://bounce.depfu.com/github.com/eslint/eslint/pull/19345">#19345</a>) (Francesco Trotta)</li> </ul></blockquote> <p><em>Does any of this look wrong? <a href="https://depfu.com/packages/npm/eslint/feedback">Please let us know.</a></em></p> </details> <details> <summary>Commits</summary> <p><a href="https://github.com/eslint/eslint/compare/1c87b415313b4aacda496b3b26efc4e0b93dc13a...208e0b199f5d5f9dd173e58e3f5db19c1f0c38ed">See the full diff on Github</a>. The new version differs by 21 commits:</p> <ul> <li><a href="https://github.com/eslint/eslint/commit/208e0b199f5d5f9dd173e58e3f5db19c1f0c38ed"><code>9.19.0</code></a></li> <li><a href="https://github.com/eslint/eslint/commit/196dfdace64d095f2facb3d8ebed1be9cb2ccab3"><code>Build: changelog update for 9.19.0</code></a></li> <li><a href="https://github.com/eslint/eslint/commit/9b9cb0584867916d50aa2e9590b132e2ef8ca59c"><code>chore: upgrade @eslint/[email protected] (#19371)</code></a></li> <li><a href="https://github.com/eslint/eslint/commit/58560e70bb4dcb305343fcd7c893ac56a404f674"><code>chore: package.json update for @eslint/js release</code></a></li> <li><a href="https://github.com/eslint/eslint/commit/cfea9abe0e27cf2ce1d27232b8c70555397e141b"><code>docs: Clarify overrideConfig option (#19370)</code></a></li> <li><a href="https://github.com/eslint/eslint/commit/2b84f666cd7474bb061e2f12205af57f5dbb89d6"><code>docs: Update README (#19362)</code></a></li> <li><a href="https://github.com/eslint/eslint/commit/044f93cbbe71a45130156004509083814e2b9669"><code>docs: clarify frozen rule description (#19351)</code></a></li> <li><a href="https://github.com/eslint/eslint/commit/797ee7c0d669678b90c5d5742228bc7b24353f79"><code>docs: fix Bluesky links (#19368)</code></a></li> <li><a href="https://github.com/eslint/eslint/commit/81a9c0ebc33dd33765711296f827c4448c80163d"><code>docs: Update README</code></a></li> <li><a href="https://github.com/eslint/eslint/commit/093fb3d40286588c2c425b738426ebfe5d142a63"><code>docs: replace `var` with `let` and `const` in rule examples (#19365)</code></a></li> <li><a href="https://github.com/eslint/eslint/commit/417de3298527e4f257e1ae7b02e1df9db3c9ed33"><code>docs: replace var with const in rule examples (#19352)</code></a></li> <li><a href="https://github.com/eslint/eslint/commit/17f2aaec16d5afbb0d219bce6ae01d7b15d74828"><code>docs: update getting-started config to match default generated config (tailwindlabs#19308)</code></a></li> <li><a href="https://github.com/eslint/eslint/commit/aae67172ab9631b4267fc03f64d3c3d6d1fcda73"><code>fix: sync rule type header comments automatically (tailwindlabs#19276)</code></a></li> <li><a href="https://github.com/eslint/eslint/commit/8a0a5a8851f72982327c2aa3a41403963f025771"><code>docs: better `global ignores` instruction (tailwindlabs#19297)</code></a></li> <li><a href="https://github.com/eslint/eslint/commit/20897070913418078d8f1ea9a877d223650dff73"><code>test: fix failing test in Node.js v22.13.0 (#19345)</code></a></li> <li><a href="https://github.com/eslint/eslint/commit/6671a2cd8ccc710fefbccad9a813c3bea5f76c68"><code>docs: Update README</code></a></li> <li><a href="https://github.com/eslint/eslint/commit/1637b8e87df5c7f58ab71e0e159f4b96c998e070"><code>feat: add `--report-unused-inline-configs` (tailwindlabs#19201)</code></a></li> <li><a href="https://github.com/eslint/eslint/commit/e39d3f22ff793db42e1f1fc3808cbb12fc513118"><code>docs: fix divider for rule category (tailwindlabs#19264)</code></a></li> <li><a href="https://github.com/eslint/eslint/commit/e0cf53f80a4b127524e0badc8999d5d1a247143f"><code>docs: fix search result box position for small screens (tailwindlabs#19328)</code></a></li> <li><a href="https://github.com/eslint/eslint/commit/f92a6803a10c66cf77408b2bf29c17bcd63b1049"><code>docs: replace var with let or const in rule examples (tailwindlabs#19331)</code></a></li> <li><a href="https://github.com/eslint/eslint/commit/b04b84bc17d4aaaea1326cb08196593624db02a2"><code>docs: revert accidental changes in TS config files docs (tailwindlabs#19336)</code></a></li> </ul> </details> ---  [Depfu](https://depfu.com) will automatically keep this PR conflict-free, as long as you don't add any commits to this branch yourself. You can also trigger a rebase manually by commenting with `@depfu rebase`. <details><summary>All Depfu comment commands</summary> <blockquote><dl> <dt>@depfu rebase</dt><dd>Rebases against your default branch and redoes this update</dd> <dt>@depfu recreate</dt><dd>Recreates this PR, overwriting any edits that you've made to it</dd> <dt>@depfu merge</dt><dd>Merges this PR once your tests are passing and conflicts are resolved</dd> <dt>@depfu cancel merge</dt><dd>Cancels automatic merging of this PR</dd> <dt>@depfu close</dt><dd>Closes this PR and deletes the branch</dd> <dt>@depfu reopen</dt><dd>Restores the branch and reopens this PR (if it's closed)</dd> <dt>@depfu pause</dt><dd>Ignores all future updates for this dependency and closes this PR</dd> <dt>@depfu pause [minor|major]</dt><dd>Ignores all future minor/major updates for this dependency and closes this PR</dd> <dt>@depfu resume</dt><dd>Future versions of this dependency will create PRs again (leaves this PR as is)</dd> </dl></blockquote> </details> Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com>
Summary
This PR adds plugin hook filters to the Vite plugin. They are backwards-compatible, having no impact on older Vite versions as the check for
isPotentialCssRootFileis still included.It can be dropped once you don't need to support older Vite versions.
See also
e18e/ecosystem-issues#171