How to bundle components into a package with tsup
Hi, new to making library stuff, I have a list of
components/
+ index.ts file
index.ts
exports most of the components, so I'd want
But there are some components which need their own dir, like
I have not made a package before so idk how bundling etc works 😦
When I ran the tsup command, it bundled the entire list of named exports in the index.ts file, what about other components which arent imported in the main index.ts
file
19 Replies
then you also need to refer to those entry points in the package json, but if you use https://github.com/solidjs-community/solid-lib-starter it is done for you
GitHub
GitHub - solidjs-community/solid-lib-starter: SolidJS library start...
SolidJS library starter template. Use it to create your own solid package. - solidjs-community/solid-lib-starter
but wouldnt it be too much manual work to hardcode entry points ?
for example most of my components are single files with default exports, like Btn, Input
so
index.ts
- User must be able to import like this
and there are few ones like Tabs, Dropdown which arent exported in index.ts
- User must import like :
but i dont want another components in my /dist!

ig i can put
index.ts
inside components but looks anti-pattern 😨
nvm i think i get what u meant now
thanksphew

nice!
tbh i have had to re-publish packages many times because i messed up the setup somewhere
i ran
treeshake:true
and tsup wiped off all .js files ðŸ˜it's a bit a mess 🙂
@bigmistqke
it gives an error

looks like it is having issues with the version where the jsx is being preserved
not sure what's up with that.
tbh i don't know if u really need to treeshake
i wouldn't minify either tbh
when building a package
let the consumer of your library deal with treeshaking and minification
does the tooling also treeshake and minify the imported modules from a lib 😮
so why do i even need a bundler now, cant i just put jsx and types generated by tsc lol
to make your library usable for the 0.1% of people that is into bundleless?
idk if i would still build cjs tbh
bundeless people i can still sympathize with, but cjs needs to go
but isnt it just importing components?
like if someone would make a dir of components in his project dir then he would write it in jsx/tsx, and not js!!!
so i just bundle in esm?
that's what i do!
GitHub
solid/packages/solid/html at main · solidjs/solid
A declarative, efficient, and flexible JavaScript library for building user interfaces. - solidjs/solid
cool