developit / microbundle

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

docs: Adding comment about file inclusion in TS section #888

Closed rschristian closed 2 years ago

rschristian commented 3 years ago

Closes #807

When building with TypeScript, we provide a default value for "files" which has the side effect of altering what files are included for compilation with Microbundle. While this is intentional (see #621) it isn't exactly obvious to users why files included when using tsc are suddenly not included when using Microbundle.

changeset-bot[bot] commented 3 years ago

⚠️ No Changeset found

Latest commit: ca4cc2b62130e5fe6f8a6fd734b143881ad002d6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

rschristian commented 3 years ago

@AndyOGo Hm, that's not a Microbundle thing. TSC wouldn't do anything differently. That's just not what that typeRoots is for.

AndyOGo commented 3 years ago

Thanks for your answer.

I have custum definition files, which I usually add by using typeRoots. And it works stable with tsc.

Though with microbundle it wont work.

My guess is because the default includes is */, but if files is specified then includes default is an empty array. I could be wrong though.

rschristian commented 3 years ago

@AndyOGo

It's exactly that, yeah. By default include covers everything, so tsc will include those ambient declarations. As Microbundle needs to alter what's included, you as the user need to specify.

Though I should say typeRoots isn't actually doing anything for you in that repo you provided. Ambient declarations will be picked up so long as they're included by files or include. You don't need typeRoots there are all. It has no effect.

Edit: It seems the only real use for typeRoots is if you wanted to say ignore all of @types/ and define your own versions maybe? Honestly I'm not too sure. The docs don't actually seem to cover when you'd want to use the option.