Skip to content

Commit 5ffcb1e

Browse files
authored
fix: preserve jsx for rolldown dep scan (#252)
1 parent 709fca1 commit 5ffcb1e

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

.changeset/six-lions-joke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'vite-plugin-solid': patch
3+
---
4+
5+
fix: preserve jsx for rolldown dep scan

src/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ const runtimePublicPath = '/@solid-refresh';
1818
const runtimeFilePath = require.resolve('solid-refresh/dist/solid-refresh.mjs');
1919
const runtimeCode = readFileSync(runtimeFilePath, 'utf-8');
2020

21-
const isVite6 = +version.split('.')[0] >= 6;
21+
const viteVersionMajor = +version.split('.')[0];
22+
const isVite6 = viteVersionMajor >= 6;
23+
const isVite8 = viteVersionMajor >= 8;
2224

2325
const VIRTUAL_MANIFEST_ID = 'virtual:solid-manifest';
2426
const RESOLVED_VIRTUAL_MANIFEST_ID = '\0' + VIRTUAL_MANIFEST_ID;
@@ -307,6 +309,13 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
307309
optimizeDeps: {
308310
include: [...nestedDeps, ...solidPkgsConfig.optimizeDeps.include],
309311
exclude: solidPkgsConfig.optimizeDeps.exclude,
312+
// Vite 8+ uses Rolldown for dependency scanning. Rolldown defaults to
313+
// React's automatic JSX runtime for .tsx files, injecting a
314+
// react/jsx-dev-runtime import. Tell it to preserve JSX as-is since
315+
// this plugin handles JSX transformation via babel-preset-solid.
316+
...(isVite8
317+
? { rolldownOptions: { transform: { jsx: 'preserve' as const } } }
318+
: {}),
310319
},
311320
...(!isVite6 ? { ssr: solidPkgsConfig.ssr } : {}),
312321
...(test.server ? { test } : {}),

0 commit comments

Comments
 (0)