question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Vite version 3.0.0-alpha.9]: Treeshaking does not work with libs.

See original GitHub issue

Describe the bug

[Vite version 3.0.0-alpha.9]: Cannot treeshaking libs. image

[Vite version 2.9.9]: Its ok. image

Reproduction

https://stackblitz.com/edit/vitejs-vite-bqjtx1?file=src%2FApp.tsx,vite.config.ts,stats.html

System Info

System:
    OS: macOS 11.6
    CPU: (8) arm64 Apple M1
    Memory: 99.69 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
    Yarn: 1.22.17 - ~/.nvm/versions/node/v16.13.0/bin/yarn
    npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
  Browsers:
    Chrome: 102.0.5005.61
    Safari: 14.1.2
  npmPackages:
    @vitejs/plugin-legacy: ^1.8.0 => 1.8.2 
    @vitejs/plugin-react: ^1.3.2 => 1.3.2 
    vite: ^3.0.0-alpha.9 => 3.0.0-alpha.9

Used Package Manager

pnpm

Logs

$ pnpm run build

> vite-antd-seed@0.0.0 build /Users/sun/Desktop/work/vite-antd-seed
> vite build

vite v3.0.0-alpha.9 building for production...
✓ 42 modules transformed.
dist/assets/favicon.4b63ffc1.svg        1.49 KiB
dist/index.html                         0.53 KiB
dist/assets/TestComponent.7cc13317.js   0.12 KiB / gzip: 0.13 KiB
dist/assets/index.0d2e4644.js           0.19 KiB / gzip: 0.17 KiB
dist/assets/index.2636713a.js           5.91 KiB / gzip: 2.51 KiB
dist/assets/esm-VW3YJATR.944f0927.js    214.24 KiB / gzip: 64.88 KiB
dist/assets/index.06cb8156.css          530.03 KiB / gzip: 67.17 KiB
dist/assets/vendor.8dd48daa.js          1696.88 KiB / gzip: 538.35 KiB

(!) Some chunks are larger than 500 KiB after minification. Consider:
- Using dynamic import() to code-split the application
- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/guide/en/#outputmanualchunks
- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.

Validations

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:18 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
rainydayDYcommented, Jul 22, 2022

I tried 3.0.0-beta.8 and 3.0.0-beta.10 and 3.0.0 and 3.0.2,tree shaking does not work

3reactions
ckvvcommented, Jul 8, 2022

@patak-dev updated to 3.0.0-beta.8 solved my problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tree shaking does not work in vite library mode - Stack Overflow
I am building a library with vite library mode, the problem is the bundler is not tree shakable. There are some related topics...
Read more >
Frontend library development with vite and tailwindcss
Shows how to develop a library using vite and tailwindcss. We'll show you how to generate typedefs, set path aliases, and configure tailwindcss...
Read more >
react-vant - NPM Package Overview - Socket - Socket.dev
Version : 1.4.7 was published by sanlang. Start using Socket to analyze react-vant and its 8 dependencies to secure your app from supply...
Read more >
Firebase JavaScript SDK Release Notes - Google
Version 9.8.1 - May 09, 2022. Authentication. Fixed some typings issues that caused compile ...
Read more >
vue | Yarn - Package Manager
For direct use via <script src="..."> in the browser. Exposes the Vue global. Note that global builds are not UMD builds. They are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found