Tree Shaking with Good DX
I'm trying to see if there's a solution where I can have a great developer experience (DX) (Ability to call elements as children of the parent like <Table.Row>) but also tree shake my primitive UI components.
Given the following code...
When importing, I'd like to use it like so... (best DX)
My understanding is that importing it as the default won't tree-shake unused elements since I'm importing the whole
Table
object
But I also don't want to do something like this where I have to import all the elements at the top. This optimizes tree-shaking but decreases developer experience
The only alternative I can think of is...
Then when using it... you can choose to import it all or if you only need a small portion you can only import that element. But I think this somewhat defeats the whole tree shaking thing as it makes it much bigger in size when importing it all.
Open to different people's ideas and thoughts on what the best approach is.1 Reply
Also, if in my application I use
Table.Header
once, does that mean it'll be included in the bundle so there's no point trying to remove tree-shake it because all other references will just be a reference to it?
So the only benefit of tree-shaking is when you DON'T use it at all anywhere in your application?