Open lovrozagar opened 3 months ago
Can you share a reproduction with both library and your next.js code? It has few factors that could effect the tree-shaking
Sorry for the late reply.
Sure here is the library repo: https://github.com/lovrozagar/renderui-core/blob/main/package.json
and nextjs starter with one import to showcase the issue: https://github.com/lovrozagar/bunchee-treshake-reproduction
I am building a component library for Next.js, using bunchee to compile but when using only one component out of many in the consumer app, my whole library is included in the built app bundle size. Looking at the build file that bunchee generates for the component library, code is split into many smaller files, I am using "use client" directive somewhere and those components are separate files too.
Maybe I am missing something. It would be good to note what is needed for tree shaking in the docs as I am unable to find more info on this topic.