developit / microbundle

📦 Zero-configuration bundler for tiny modules.
https://npm.im/microbundle
MIT License
8.06k stars 361 forks source link

Missing d.ts files due to invalid test file #855

Closed Eyal-VR closed 3 years ago

Eyal-VR commented 3 years ago

Hi! I've seen some issues here regarding missing d.ts files (e.g. https://github.com/developit/microbundle/issues/669)

My situation was like this: Everything was working perfectly until I've added a new file and its corresponding test file (test.tsx). The problem with the test file was that I forgot to wrap it with describe("Component Tests", () => {}

Tests were working properly, and the build was successful but no d.ts were emitted.

when I added the describe wrapper, the d.ts files were emitted properly

rschristian commented 3 years ago

Did you have the test file included in your tsconfig.json that you used with Microbundle? Sounds like an upstream issues with rpt2 though, if it doesn't provide any warnings on failure to generate output.

Eyal-VR commented 3 years ago

Yes, tests files are included in tsconfig.json

rschristian commented 3 years ago

You definitely don't want them included in the TSConfig you're using with Microbundle. TS will generate types and output for each file it finds. If you run Microbundle with those tests included, you're going to get those types in your output directory. That's how base TSC works, this isn't Microbundle-specific.

Create a tsconfig.build.json that only includes your source files and pass this path to Microbundle. That'll make sure only your source files are included.

As for this issue though, as far as I can tell it's an upstream thing. We just use rollup-plugin-typescript2 to do the TypeScript stuff. If it doesn't output when it encounters an error, and has no warning, that's something for it to solve I believe.

rschristian commented 3 years ago

Going to close this out as there's not really anything further for us to do, at least not without the verbose logs from rtp2