Skip to content
Merged
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
4 changes: 4 additions & 0 deletions packages/plugin-react-swc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Skip HMR preamble in Vitest browser mode

This was causing annoying `Sourcemap for "/@react-refresh" points to missing source files` and is unnecessary in test mode.

## 3.9.0 (2025-04-15)

### Make compatible with rolldown-vite
Expand Down
18 changes: 11 additions & 7 deletions packages/plugin-react-swc/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,17 @@ const react = (_options?: Options): PluginOption[] => {
)
}
},
transformIndexHtml: (_, config) => [
{
tag: 'script',
attrs: { type: 'module' },
children: getPreambleCode(config.server!.config.base),
},
],
transformIndexHtml: (_, config) => {
if (!hmrDisabled) {
return [
{
tag: 'script',
attrs: { type: 'module' },
children: getPreambleCode(config.server!.config.base),
},
]
}
},
async transform(code, _id, transformOptions) {
const id = _id.split('?')[0]
const refresh = !transformOptions?.ssr && !hmrDisabled
Expand Down
Loading