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

Tree shaking doesn't work (Vite + React + MUI) #9137

Closed
7 tasks done
fpolic-profico opened this issue Jul 15, 2022 · 1 comment
Closed
7 tasks done

Tree shaking doesn't work (Vite + React + MUI) #9137

fpolic-profico opened this issue Jul 15, 2022 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@fpolic-profico
Copy link

Describe the bug

I installed a fresh version of Vite + React (TS). Also added MUI (https://mui.com) and imported a Button component. When I default import the Button, only that module is downloaded in the network tab. However, if I import the Button as named import the whole MUI library is imported. Here are some screenshots:

Default import
Screenshot 2022-07-15 at 13 11 35

Named import
Screenshot 2022-07-15 at 13 10 32

I also tried migrating one of my CRA projects to Vite but ended up rendering a blank page without any errors. There are a lot of index file import/exports there and I suspect, since tree shaking isn't working, those index file somehow caused a dependency cycle which caused the renderer to silently fail. If someone has an idea how I could fix that (if there's something on my end I did wrong) please let me know.

Reproduction

https://stackblitz.com/edit/vite-react-ts-hv4zat

System Info

System:
    OS: macOS 12.1
    CPU: (8) arm64 Apple M1
    Memory: 152.97 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
Binaries:
    Node: 16.15.0 - ~/.nvm/versions/node/v16.15.0/bin/node
    Yarn: 1.22.18 - ~/.nvm/versions/node/v16.15.0/bin/yarn
    npm: 8.5.5 - ~/.nvm/versions/node/v16.15.0/bin/npm
    Watchman: 2021.10.18.00 - /usr/local/homebrew/bin/watchman
Browsers:
    Chrome: 103.0.5060.114
    Firefox Developer Edition: 97.0
    Safari: 15.2
npmPackages:
    @vitejs/plugin-react: ^2.0.0 => 2.0.0 
    vite: ^3.0.0 => 3.0.0

Used Package Manager

yarn

Logs

No response

Validations

@sapphi-red
Copy link
Member

Closing as tree-shaking one is a duplicate of #8237.

There are a lot of index file import/exports there and I suspect, since tree shaking isn't working, those index file somehow caused a dependency cycle which caused the renderer to silently fail.

This sounds like #3033.

@sapphi-red sapphi-red closed this as not planned Won't fix, can't repro, duplicate, stale Jul 16, 2022
@sapphi-red sapphi-red added duplicate This issue or pull request already exists and removed pending triage labels Jul 16, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jul 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants