Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin-react-refresh should skip worker files #1841

Closed
buffaybu opened this issue Feb 2, 2021 · 1 comment
Closed

plugin-react-refresh should skip worker files #1841

buffaybu opened this issue Feb 2, 2021 · 1 comment

Comments

@buffaybu
Copy link
Contributor

buffaybu commented Feb 2, 2021

Describe the bug

If a worker file includes react string and a function, react-refresh code including /@vite/client which references HTMLElement will be injected to the worker code, causing Uncaught ReferenceError: HTMLElement is not defined .

// plain js/ts files can't use React without importing it, so skip
// them whenever possible
if (!id.endsWith('x') && !code.includes('react')) {
return
}

Reproduction

https://github.com/buffaybu/vite-env-example/tree/react-refresh (react-refresh branch)

Replace "react" with "1" and the error is gone.

System Info

  • @vitejs/plugin-react-refresh version: 1.1.3
  • vite version: 2.0.0-beta.50
  • Operating System: macOS 11.1
  • Node version: 14.15.0
  • Package manager (npm/yarn/pnpm) and version: yarn
@yyx990803
Copy link
Member

Incidentally this is now fixed after 5735692 because worker files now have a query.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants