Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .changeset/vite8-scan-jsx-classic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
'vite-plugin-solid': patch
---

Vite 8's dependency scan no longer breaks on `.tsx` files (issue #262).
The plugin previously set `optimizeDeps.rolldownOptions.transform.jsx:
'preserve'` to stop Rolldown from injecting `react/jsx-dev-runtime`
imports during the scan — but the scanner re-parses the transformed
output as plain JS (`import.meta.glob` handling force-tags modules as
`js`), so any `.tsx` with JSX was a hard `PARSE_ERROR: Unexpected JSX
expression` that aborted the whole scan and skipped pre-bundling. The
scan transform now uses the classic JSX runtime, which lowers JSX to bare
`React.createElement` calls without injecting any import: the scan output
is never executed, it only exists so rolldown can walk the import graph,
so the undefined identifier is harmless. Backport of the fix already on
the 3.0.0-next line.
11 changes: 8 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,15 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
exclude: solidPkgsConfig.optimizeDeps.exclude,
// Vite 8+ uses Rolldown for dependency scanning. Rolldown defaults to
// React's automatic JSX runtime for .tsx files, injecting a
// react/jsx-dev-runtime import. Tell it to preserve JSX as-is since
// this plugin handles JSX transformation via babel-preset-solid.
// react/jsx-dev-runtime import that fails to resolve and aborts the
// scan. 'preserve' is no fix: the scanner re-parses the transformed
// output as plain JS, so any preserved JSX is a hard parse error
// (issue #262). The classic runtime is the only scan-safe lowering:
// it emits bare `React.createElement` calls without injecting any
// import, and the scan output is never executed — it only exists so
// rolldown can walk the import graph.
...(isVite8OrNewer
? { rolldownOptions: { transform: { jsx: 'preserve' as const } } }
? { rolldownOptions: { transform: { jsx: { runtime: 'classic' as const } } } }
: {}),
},
...(!isVite6OrNewer ? { ssr: solidPkgsConfig.ssr } : {}),
Expand Down
Loading