threepointone/glamor

Separate exported functions into dedicated files

Closed this issue · 2 comments

Love the library, use it on several projects, but one big hiccup is the fact that all of the named exports (css, simulate, etc.) all part of this large index file, which means when you import one, you import them all. Tree-shaking in webpack does not help much with this, so I was hoping for a route that follows something like lodash ... where the exports are also their own dedicated files. Something like import css from 'glamor/lib/css'; would produce a much smaller bundle size for the consumer if they are not making use of all of the features, and it basically just involves plopping the code into a dedicated file and then doing an import / export pass through on index.

I know you were tackling a lot of backlog items right now, and that bundle size was a big one ... this would not necessarily lower the bundle size of the package, but would help lower the bundle sizes of all the consumers who use this package. What do you think?

Definitely on my radar, thanks for bringing this up, I will likely take the approach you've outlined. It'll happen a bit slowly though, want to make sure I'm not breaking stuff for people. But yes, you should expect to shave a couple of kb at least in a month or so, and I hope to have codemods/plugins that'll make it easier for older codebases to move to this.

Rock on! Thanks for the quick response. :)