Tree shake big bundle size
See original GitHub issueI’m trying the amazing Shoelace for the first time today.
I’m working on a project with Rollup.
Everything works and is amazing.
One thing I don’t like though.
Just adding the following lines of code to my project increases it by 232 KB (from 747 KB to 979 KB) javascript side only.
import { SlButton } from '@shoelace-style/shoelace'
customElements.define('sl-button', SlButton)
If I use this instead it increases by 383 KB (from 747 KB to 1130 KB).
import { defineCustomElements } from '@shoelace-style/shoelace'
defineCustomElements()
As you can see from the images we have @stencil/core/internal/client/index.js
of ~ 16 KB. Is it really needed?
Is it really necessary to have those 232 KB all together? Can we tree-shaking?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:19 (10 by maintainers)
Top Results From Across the Web
PCF Controls - Tree-Shaking For Better Bundle Size
In this post I will show how to optimize the tree-shaking process and reduce the bundle size of PCF controls with simple adjustments...
Read more >Reduce JavaScript payloads with tree shaking - web.dev
These are uncompressed sizes. The JavaScript bundles shown in the figure above are production builds, meaning they're optimized through uglification. 21.1 KB ......
Read more >Does my bundle look big in this? - LogRocket Blog
Tree shaking is a technique used to eliminate dead code. ... Step 1 of any journey to a smaller bundle size is to...
Read more >ES6 Tree Shaking build large bundle size - Babylon.js Forum
ES6 Tree Shaking build large bundle size ... I import the dependencies this way, finally get 1.5M ungzip js file. Is this correct?...
Read more >Tree-Shaking: A Reference Guide - Smashing Magazine
Tree-shaking” is a must-have performance optimization when bundling ... takes bundle size very seriously, they have made tree-shaking easy.
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 Free
Top 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
This has been resolved in beta 28 which no longer uses Stencil. The new dist contains a collection of ES modules so you can load everything, cherry pick components, or import with a bundler.
Part of the solution was adding the
sideEffects
property in Shoelace’spackage.json
so bundlers will see it. This enables tree-shaking in Rollup with zero config, but webpack users need to add this flag in their config. Not sure about other bundlers.I’m working on an experimental build using Shoemaker and esbuild that resolves this. The end result is a collection of ES modules that are properly tree-shaken and split into chunks. The nice thing about this is that the same bundle can be served from a browser and into webpack/Rollup/etc.
I’ll post more details once I get a bit further with it.