developit / microbundle

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

feat: Expands generateTypes flag to support TS entries #865

Closed rschristian closed 3 years ago

rschristian commented 3 years ago

What kind of change does this PR introduce?

Feature, expands the --generateTypes flag to also support projects with TS entry points.

Did you add tests for your changes?

Modified an existing test

Summary

Closes #863

The problem with the existing --generateTypes behavior is that it is only relevant when used with JS entry points.

emitDeclaration is derived from options.generateTypes and is only used in the following spot:

https://github.com/developit/microbundle/blob/b1a637486234a2ae784ccf0c512321e2d3efef7c/src/index.js#L510

Which means that when useTypescript is truthy, that option holds no power whatsoever. useTypescript would be truthy on any project that had TS entry points:

https://github.com/developit/microbundle/blob/b1a637486234a2ae784ccf0c512321e2d3efef7c/src/index.js#L387

To allow projects with TS entry points to disable types from being output, we now simply disable TS's declaration compiler option if options.generateTypes is set to false.

Does this PR introduce a breaking change?

No

changeset-bot[bot] commented 3 years ago

🦋 Changeset detected

Latest commit: 26777482553c43969de63398f2b1c9600e7ffdc4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ----------- | ----- | | microbundle | Patch |

Not sure what this means? Click here to learn what changesets are.

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