Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 2 additions & 1 deletion packages/plugin-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,15 @@ export default function viteReact(opts: Options = {}): Plugin[] {

const isJSX = filepath.endsWith('x')
const useFastRefresh =
!isRolldownVite &&
!skipFastRefresh &&
!ssr &&
(isJSX ||
(opts.jsxRuntime === 'classic'
? importReactRE.test(code)
: code.includes(jsxImportDevRuntime) ||
code.includes(jsxImportRuntime)))
if (useFastRefresh && !isRolldownVite) {
if (useFastRefresh) {
plugins.push([
await loadPlugin('react-refresh/babel'),
{ skipEnvCheck: true },
Expand Down
1 change: 1 addition & 0 deletions playground/compiler/__tests__/compiler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ test('should render', async () => {
expect(await page.textContent('button')).toMatch('count is 0')
expect(await page.click('button'))
expect(await page.textContent('button')).toMatch('count is 1')
expect(await page.textContent('.class-component')).toMatch('ClassComponent')
})

test.runIf(isServe)('should hmr', async () => {
Expand Down
2 changes: 2 additions & 0 deletions playground/compiler/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useState } from 'react'
import './App.css'
import { ClassComponent } from './ClassComponent'

export function App() {
const [count, setCount] = useState(0)
Expand All @@ -18,6 +19,7 @@ export function App() {
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
<ClassComponent />
</>
)
}
7 changes: 7 additions & 0 deletions playground/compiler/src/ClassComponent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Component } from 'react'

export class ClassComponent extends Component {
public render() {
return <div className="class-component">ClassComponent</div>
}
}
Loading