egoist / tsup

The simplest and fastest way to bundle your TypeScript libraries.
https://tsup.egoist.dev
MIT License
8.49k stars 209 forks source link

tree shaking not working with your tailwind example #1005

Closed Jared-Dahlke closed 9 months ago

Jared-Dahlke commented 9 months ago

I copied your tailwind example you just made and added react: https://github.com/Jared-Dahlke/tsup-shadcn

the tailwind works now which is great! But now tree shaking is not working. In my example i am expecting Button to be about 10kb and Accordion to add more weight once it's imported. But it looks like the import size is including everything even if you only import Button.

import { Button } from "tsup-tailwind-react-shadcn"; should only be about 10kb

Any idea what I am doing wrong?

Upvote & Fund

Fund with Polar

ocavue commented 9 months ago

I'm not seeing React in Jared-Dahlke/tsup-shadcn. Did you forget to push your code?

Jared-Dahlke commented 9 months ago

@ocavue my bad, you were right i forgot to push. It is now pushed. Do you mind trying it out please? Thank you!

Everything works except tree shaking (which is very important to me)

ocavue commented 9 months ago

Your repo cannot be built because you missed the react in the dependencies field of package.json.

I added react in package.json and ran the build script, the output file dist/index.mjs and dist/index.js look good to me. dist/index.mjs has 94 lines, and dist/index.js has 118 lines. I don't understand "tree shaking is not working" and I also don't know how you get the conclusion of "the import size is including everything".

Anyway, don't see any issue on the tsup side. Going to close this issue for now.