Skip to content

Commit

Permalink
Revert "fix: reactPlugin skip inject react hmr code to workerFile (fix
Browse files Browse the repository at this point in the history
…vitejs#6148)"

This reverts commit 136883d.
  • Loading branch information
aleclarson committed Jan 4, 2022
1 parent 2825779 commit 107aacb
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions packages/plugin-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,6 @@ export default function viteReact(opts: Options = {}): PluginOption[] {

if (/\.(mjs|[tj]sx?)$/.test(extension)) {
const isJSX = extension.endsWith('x')
// as worker, querystring could be
// import MyWorker from './worker?worker' => worker
// import MyWorker from './worker?worker&inline' => worker&inline
// transformed by webWorkerPlugin :'/worker?worker_file' => worker_file
const isWorker = querystring.includes('worker')
const isNodeModules = id.includes('/node_modules/')
const isProjectFile =
!isNodeModules && (id[0] === '\0' || id.startsWith(projectRoot + '/'))
Expand All @@ -123,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') && !isWorker)
const isReactModule = isJSX || code.includes('react')
if (isReactModule && filter(id)) {
useFastRefresh = true
plugins.push([
Expand Down

0 comments on commit 107aacb

Please sign in to comment.