Comment by vlod
6 days ago
Wouldn't tree-shaking take care of this? i.e. If I only use 'Button' (from the UI library), nothing else should be included in the (production) bundle.
6 days ago
Wouldn't tree-shaking take care of this? i.e. If I only use 'Button' (from the UI library), nothing else should be included in the (production) bundle.
Not in practice, because these UI libraries usually have many intertwined interdependencies. <Button /> probably still imports all of the context providers, which also import their own dependencies, etc. So you end up including half of the library if not more just for a button, but if you use multiple components from the library the cost is amortised.
And typically if you're just using a single component it's one that is more complex than a button, like a popover or colour picker. Which then pulls in other components, etc.