-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Vite Build include unused variable(s) #16319
Comments
Start a new pull request in StackBlitz Codeflow. |
The statement is included in the output because it has a sideeffect. That code accesses a global variable Closing as this is an expected behavior. |
Hi @sapphi-red , sorry Code change:
Could you check again? |
That is expected as well because property access is assumed to have sideeffects. |
Describe the bug
Vite Build include unused variable(s) when the components are short circuit evaluation
src/Layout/LeftSidebar.jsx
has a variable declare as array and map intoLink
component fromreact-router-dom
the
src/Layout/LeftSidebar.jsx
is imported insrc/Layout/Header.jsx
while
src/Layout/Header.jsx
is imported and short circuit evaluated insrc/Layout/index.jsx
Actual output:
Variables declare in
src/Layout/LeftSidebar.jsx
included in outputExpected output:
Variables declare in
src/Layout/LeftSidebar.jsx
or any components that short circuit evaluated(false)
should not included in outputReproduction
https://stackblitz.com/edit/vitejs-vite-rjt1ta?file=src%2Fpages%2FLayout%2FLeftSidebar.jsx
Steps to reproduce
Run
npm run build
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: