You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Vite build for our application started failing after upgrading @vitejs/plugin-react from 2.0.0 to 2.0.1.
I was able to reproduce this error in the repository https://github.com/milang/vite-issues, branch plugin-react-201. It contains acme-app generated using create-vite@3.0.2, and a simple acme-lib that represents our internal library that is causing the build to fail. Reproduction steps:
git clone https://github.com/milang/vite-issues.git
cd vite-issues
git checkout plugin-react-v201
pnpm install
pnpm run -C packages/acme-app build
# => fails with# [vite:react-babel] C:\Users\milang\dev\vite-issues\packages\acme-lib\src\styled.ts: Support for the experimental syntax 'flow' isn't currently enabled (3:8):# ...
Actual behaviour: Build fails Expected behaviour: Build succeeds
Note 1
A follow-up branch plugin-react-v200 reverts @vitejs/plugin-react back to 2.0.0. Switching to this branch makes the build succeed:
# (same directory as above)
git checkout plugin-react-v200 # switch to branch with @vitejs/plugin-react@2.0.0
pnpm install
pnpm run -C packages/acme-app build
# => build succeeds
Note 2
As I was experimenting with the reproduction steps, I noticed that I can simply rename styled.ts to styled.tsx (changing the file extension), after which the build succeed. While this is a simple "fix", behaviour of version 2.0.0 was IMO much better because it worked without a rename (and rename might not be possible when dealing with a 3rd party library).
# (same directory as above)
git checkout plugin-react-v201 # switch back to branch with @vitejs/plugin-react@2.0.1
pnpm install
mv packages/acme-lib/src/styled.ts packages/acme-lib/src/styled.tsx # change extension of the problematic file
pnpm run -C packages/acme-app build
# => build succeeds
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
The text was updated successfully, but these errors were encountered:
milang
changed the title
Vite build fails when library has React code in ".ts" file
Vite build fails when library has React code in a ".ts" file
Aug 13, 2022
Describe the bug
Vite build for our application started failing after upgrading
@vitejs/plugin-react
from2.0.0
to2.0.1
.I was able to reproduce this error in the repository https://github.com/milang/vite-issues, branch
plugin-react-201
. It containsacme-app
generated usingcreate-vite@3.0.2
, and a simpleacme-lib
that represents our internal library that is causing the build to fail. Reproduction steps:Actual behaviour: Build fails
Expected behaviour: Build succeeds
Note 1
A follow-up branch
plugin-react-v200
reverts@vitejs/plugin-react
back to2.0.0
. Switching to this branch makes the build succeed:Note 2
As I was experimenting with the reproduction steps, I noticed that I can simply rename
styled.ts
tostyled.tsx
(changing the file extension), after which the build succeed. While this is a simple "fix", behaviour of version2.0.0
was IMO much better because it worked without a rename (and rename might not be possible when dealing with a 3rd party library).Reproduction
https://github.com/milang/vite-issues/tree/plugin-react-v201
System Info
Used Package Manager
pnpm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: