Closed lilouartz closed 4 months ago
Ended up writing a post generation script to fix this.
@lilouartz
This is an interesting topic. I understand that there are some downsides to using asterisk exports like:
export * from './avatar'
Since the compiler/transpiler needs to resolve each export individually. However, I thought this kind of import should be fine as the compiler knows what it resolves:
import * as Avatar from '~/components/ui/avatar'
We use this approach to abstract away whether the user should use * as
or a normal import syntax:
import * as Avatar from '~/components/ui/avatar'
// or
import { Avatar } from '~/components/ui/avatar'
Could you provide some numbers to verify your claim about tree shaking and bundle size?
@cschroeter wow, this latest update is great! Thank you so much ❤️
Looks like at some point a barrel file was introduced.
This is causing a whole host of problems tree shaking the bundle and also the build times have substantially increased.
Normally, I would just make sure that the file is not referenced anywhere in my codebase (or just delete it). But the problem is that the barrel file is also referenced within the component library.
I ended up rewriting all references in the generated code, e.g.
avatar.tsx
:However, I would greatly appreciate if you consider dropping this pattern.