jaredpalmer / tsdx

Zero-config CLI for TypeScript package development
https://tsdx.io
MIT License
11.26k stars 508 forks source link

Multiple Entries - `--entry` exists but not documented well/broken #739

Closed neilchaudhuri closed 4 years ago

neilchaudhuri commented 4 years ago

I am building a React component library for the design system in our organization and have a bunch of components (and supporting objects like enums and interfaces) inside src. As they are not in index.tsx they aren't making it into the bundle although the type definitions are being created.

And when I do this: tsdx build --entry src/**/**.tsx

It just pulls the first file in the first directory under src.

I have noticed some issue threads here on multiple entry support, and it seems to be supported. But I don't see any documentation as to how. I would appreciate if you could point me to that or let me know if in fact such support doesn't exist. I just wanted to check here before bringing in something else like plugin-multi-entry.

agilgur5 commented 4 years ago

Sorry about that, it is actually not supported. I believe that flag (I didn't add it) was added for multi-entry but was never quite working; this issue actually duplicates #175 . I added #367 as one of my first PRs to fix this actually, but it's been somewhat stalled, first on reviews (I eventually became a maintainer and am the only active one right now), and then on some manual steps it requires and some breaking changes involved.

It'll likely release with manual steps involved as, per the PR comments, I am not really sure of a non-intrusive way of automating it.

I've gotten a bit busy so I'm behind on releases, but as a result there's more time in-between where breaking changes can be shipped, so I'll likely end up shipping the bigger, completed, breaking issues faster and smaller changes in between to go with that cadence and not stall breaking things so much.

neilchaudhuri commented 4 years ago

No worries. No one likes documentation, and it isn't always reliable. I was just confused by the switch itself and the description of supporting "Entry module(s)."

So given that, what are the best practices for where I have created tens of components like Button.tsx, Text.tsx, Link.tsx, etc. (and each with supporting primitives like enums and type declarations)? Do I copy the contents into index at build/publish time manually? Do I try to mess with @rollup/plugin-multi-entry (which I have FWIW)?

As I am sure this is a solved problem, I would love to know how the community approaches it.

agilgur5 commented 4 years ago

No one likes documentation, and it isn't always reliable.

I wouldn't say "no one likes docs", I write a ton all the time, that PR even has some. But yes, they are unfortunately not always reliable. Though in this case, it's actually that the feature was never quite fully worked out (I have also added LOTS of tests to the codebase so these things don't occur often), so now that's a bug rather than a docs issue.

As I am sure this is a solved problem, I would love to know how the community approaches it.

Wellllll it's actually not a solved problem because that PR stalled. You hit the nail on the head there unfortunately. There's various internal changes there so I don't believe plugin-multi-entry alone would make it possible. In the meantime, you can use my fork in that PR (which is a bit dated/needs rebasing; there's directions in the comments), or follow a pattern similar to https://github.com/jaredpalmer/tsdx/issues/713#issuecomment-633121874