developit / microbundle

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

Remove declaration dir warning when declarations are disabled #912

Open andyrichardson opened 2 years ago

andyrichardson commented 2 years ago

About

Given the following tsconfig

{
  "compilerOptions": {
    "declaration": false
  }
}

The user will see this message whenever building

rpt2: options error TS5069: Option 'declarationDir' cannot be specified without specifying option 'declaration' or option 'composite'.

This PR introduces a check to only provide a declarationDir option to rollup if declarations aren't omitted.

Other stuff

This is just a proposal - the tsconfig.json would need to be properly interpreted in order to get the declaration value (e.g. to cover extends).

changeset-bot[bot] commented 2 years ago

⚠️ No Changeset found

Latest commit: 7f3591069ee2b710ecce15f85f8d4b0aa2b288f5

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 2 years ago

I'm thinking we can just alter emitDeclaration to check for tsconfig.compilerOptions.declaration too (and accordingly change the condition for adding declarationDir to emitDeclaration)

Check options.generateTypes then tsconfig.compilerOptions.declaration and finally !!(pkg.types || pkg.typings). That should cover all the bases

Edit: The case of extends might be something that's acceptable to skip over for now. Mono-repo support (which is where I imagine the need for extending most often comes from) is already pretty limited by rpt2, making Microbundle not the best tool to use if that's the need.