Tree shaking not working
See original GitHub issueI have a minimal bootstrap-vue application. I basically just used the Vue CLI to create a new project, and added bootstrap-vue as follows:
import BootstrapVue from "bootstrap-vue";
import "bootstrap/dist/css/bootstrap.css";
import "bootstrap-vue/dist/bootstrap-vue.css";
Vue.use(BootstrapVue);
I also added font-awesome but that doesn’t appear to take up that much space…
When I perform a build using the Vue UI the build size seems enormous:
File Size Gzipped
dist/js/chunk-vendors.efb23010.js 422.49 KiB 131.86 KiB
dist/js/app.7c82e299.js 7.65 KiB 2.82 KiB
dist/js/about.3a94e576.js 0.44 KiB 0.31 KiB
dist/css/chunk-vendors.f1000a76.css 171.00 KiB 24.30 KiB
dist/css/app.03795e02.css 0.53 KiB 0.31 KiB
I found another thread mentioning build size and it mentioned something about “esm” builds and I tried using a different import, but barely any difference:
//import BootstrapVue from "bootstrap-vue/dist/bootstrap-vue.esm.min";
Any suggestions? Thanks.
Issue Analytics
- State:
- Created 5 years ago
- Comments:19 (7 by maintainers)
Top Results From Across the Web
Webpack Tree Shaking not working when importing from a file ...
If I remove the moment import from module.js tree shaking works fine and i only see square in my bundle. Is this how...
Read more >Tree Shaking - webpack
Tree shaking is a term commonly used in the JavaScript context for dead-code elimination. It relies on the static structure of ES2015 module...
Read more >Tree-shaking not working in v3 beta · Issue #8713 · vitejs/vite
I upgraded Vite to 3.0.0-beta.0 to resolve this issue, which prevents me from using v2.9 right now. However, tree-shaking fails for every ...
Read more >Tree-Shaking: A Reference Guide - Smashing Magazine
There's one specific issue that is unfortunately rather common and can be devastating for tree-shaking. In short, it happens when you're working ......
Read more >How I fixed webpack tree shaking in 3 easy steps
Tree shaking is an important step in Webpack bundling to get rid of unused stuff. This should help describe how to easily get...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Try this:
This should treeshake better.
Also note that Webpack 4 typically only treeshakes in production mode (https://webpack.js.org/guides/tree-shaking/#conclusion)
@tmorehouse Thank you, you are my hero of the day! 💋
Now its only
163KB
(I create the webpack analyzer reports with
nuxt build -a
, quick and easy and in production mode by default)