jaredpalmer / tsdx

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

[tsdx build] only one JS file output? #698

Closed JonasBa closed 4 years ago

JonasBa commented 4 years ago

Running tsdx build emits only direct children of the src folder and only emits .d.ts declarations for the rest.

My dir structure like below where src/index.ts imports some queue implementation from queue/index.ts

src/
   - index.ts
   - queue/
        index.ts
        queue.ts

What happens is that after running tsdx build, the dist folder seems to contain only type declarations for the queue and not the actual implementation like so:

src/
   - index.js
   - queue/
        queue.d.ts

I've tried modifying the include property of tsconfig.json to use include: ["src/**/*"] but that didn't result in the implementation being emitted in the build.

P.S: sorry if this is a newb question, it's my first time using tsdx 😅

agilgur5 commented 4 years ago

Please don't remove issue templates, they are there for a reason.

Running tsdx build emits only direct children of the src folder and only emits .d.ts declarations for the rest.

Neither of those is exactly accurate.

TSDX only builds src/index.ts (or variants of it, like .tsx, .js, .jsx), not "only direct children". Its tree of imports is bundled into its single JS output file with Rollup.

Type declarations, i.e. .d.ts files, are emitted based on whatever your tsconfig include has, which should be just src and types.

the dist folder seems to contain only type declarations for the queue and not the actual implementation

Yes, it has been tree-shaken and bundled into your one JS file. Check the contents of your bundled file.


I'm simplifying by saying "one JS file output", there is at least one per format (ESM, CJS, etc), sometimes multiple if dev/prod variants are possible in the given format. These are all bundles of the same thing, just different formats.