Skip to content

Commit

Permalink
fix(plugin-react): handle react-refresh 0.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Apr 4, 2022
1 parent 9af611a commit ad462d9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions packages/plugin-react/src/fast-refresh.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import type { types as t } from '@babel/core'
import fs from 'fs'
import path from 'path'

export const runtimePublicPath = '/@react-refresh'

const runtimeFilePath = require.resolve(
'react-refresh/cjs/react-refresh-runtime.development.js'
const reactRefreshDir = path.dirname(
require.resolve('react-refresh/package.json')
)
const runtimeFilePath = path.join(
reactRefreshDir,
'cjs/react-refresh-runtime.development.js'
)

export const runtimeCode = `
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
if (isReactModule && filter(id)) {
useFastRefresh = true
plugins.push([
await loadPlugin('react-refresh/babel.js'),
await loadPlugin('react-refresh/babel'),
{ skipEnvCheck: true }
])
}
Expand Down

0 comments on commit ad462d9

Please sign in to comment.