Skip to content

Commit

Permalink
fix(plugin-react): check for import React statement in .js files
Browse files Browse the repository at this point in the history
…instead of using naïve `code.includes("react")` check
  • Loading branch information
aleclarson committed Jan 4, 2022
1 parent 107aacb commit 15f6fd6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/plugin-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
let useFastRefresh = false
if (!skipFastRefresh && !ssr && !isNodeModules) {
// Modules with .js or .ts extension must import React.
const isReactModule = isJSX || code.includes('react')
const isReactModule = isJSX || importReactRE.test(code)
if (isReactModule && filter(id)) {
useFastRefresh = true
plugins.push([
Expand Down

0 comments on commit 15f6fd6

Please sign in to comment.