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.

Tree shake big bundle size

See original GitHub issue

I’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)

image

If I use this instead it increases by 383 KB (from 747 KB to 1130 KB).

import { defineCustomElements } from '@shoelace-style/shoelace'

defineCustomElements()

image

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:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:19 (10 by maintainers)

github_iconTop GitHub Comments

18reactions
claviskacommented, Feb 26, 2021

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’s package.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.

4reactions
claviskacommented, Feb 22, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

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