Skip to content

fix: compile ids whose extension follows the query - #444

Open
lxsmnsyc wants to merge 2 commits into
mainfrom
fix/206-query-before-extension-main
Open

lxsmnsyc wants to merge 2 commits into
mainfrom
fix/206-query-before-extension-main

Conversation

@lxsmnsyc

Copy link
Copy Markdown
Member

Fixes #206 on main (1.x). The fix for next is in a separate PR.

Icons from unplugin-icons with compiler: 'solid' and a query, such as ~icons/mdi/folder?width=2em, are compiled by Solid again. Since 2.11.2 they were left to Vite's default JSX transform, which emits React code.

Cause

  • unplugin-icons puts the extension after the query: ~icons/mdi/folder?width=2em.tsx.
  • The plugin removes the query before it checks the extension, so it saw no JSX extension and skipped the module.

Changes

  • If the path without its query is not a JSX file but the full id is, the plugin compiles it.
  • getExtension now removes the query before it looks for the extension. Before, a custom extension followed by a query containing a ., such as a.mdx?x=1.5, was skipped.

Testing

  • Reproduced with an icon import that has a query. Vite 8 failed to build on react/jsx-dev-runtime, and the dev server returned 500. Published 2.11.1 compiled it correctly.
  • With the fix, the icon compiles to Solid output.
  • Added regression tests for both cases. They fail without the fix.
  • vitest run and tsc --noEmit pass. The vite-5, vite-6 and vite-8 examples build.

Note on the first commit

main had no unit tests. The first commit adds the same Vitest setup that next uses: a root vitest.config.ts, a test:unit script, and a step in the Vitest workflow. The other main fix PRs from this batch (#112, #153, #206, #130, #141) share this exact commit, so they do not conflict on it.

🤖 Generated with Claude Code

lxsmnsyc and others added 2 commits October 19, 2026 11:34
- Add a root vitest config and a test:unit script, matching the next branch.
- Run the unit tests in the vitest workflow.
- Exclude test files from the declaration build.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- Since 2.11.2 the transform stripped the query before checking the extension. Ids like unplugin-icons' `~icons/mdi/folder?width=2em.tsx` then had no extension, so Vite compiled their JSX for React.
- When the query-free path is not a JSX file but the full id is, compile the full id.
- Read custom extensions from the query-free path. A dot in the query (`a.mdx?x=1.5`) was read as the extension and the module was skipped.
- Add dev transform tests for both cases.

Fixes #206

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Oct 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: df3ba8a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
vite-plugin-solid Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Oct 19, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/vite-plugin-solid@444

commit: df3ba8a

@ryansolid ryansolid added the 1.x label Oct 21, 2026 — with Claude
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vite-plugin-solid 2.11.2 and onwards (up to 2.11.6) breaks unplugin-icons/vite with "solid" icon compiler

2 participants