jaredpalmer / tsdx

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

build is empty without src/index file #993

Closed y-nk closed 3 years ago

y-nk commented 3 years ago

Current Behavior

I've setup a project with the react+storybook template, but instead of having the Thing component, I've changed to have a sub folder structure instead (with components/ and sub folders components/Button/ ). The result is that, when calling yarn build, all types of build are empty files.

Expected behavior

both cjs and esm builds should work event with subfolder structures.

Suggested solution(s)

maybe there's something to do with the entry point at compile time?

Additional context

 System:
    OS: macOS 11.2.3
    CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
    Memory: 385.52 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 15.0.1 - ~/.nvm/versions/node/v15.0.1/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.10 - ~/.nvm/versions/node/v15.0.1/bin/npm
  Browsers:
    Chrome: 89.0.4389.90
    Firefox: 84.0.1
    Safari: 14.0.3
  npmPackages:
    tsdx: ^0.14.1 => 0.14.1
    typescript: ^4.2.3 => 4.2.3
y-nk commented 3 years ago

Deleting the dist/ and running the command again fixed it. Not sure why but it's no longer a pb.

agilgur5 commented 3 years ago

You've edited your comment, but yes, TSDX assumes you have an entrypoint at src/index unless you've specified otherwise. In this case, you didn't specify a different entrypoint and didn't have anything at src/index, hence the empty builds.

I didn't write this code, but aside from being poor style with many ternaries, your issue points out that it doesn't properly error check -- it should error out in the case where the entrypoint file doesn't exist. That would be better DX as feedback to the user. I'm somewhat surprised that Rollup itself doesn't error though at this case though.

y-nk commented 3 years ago

oh wow thanks for the feedback @agilgur5 :)