Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support
emitDeclarationOnly
(#366)
- when `emitDeclarationOnly` is set, only perform type-checking and emit declarations, don't transform TS - `result.code` actually doesn't exist when `emitDeclarationOnly` is set anyway - this caused a confusing situation for users who were trying to use Babel (with Babel plugins) on TS and only use rpt2 for declarations - instead of getting any JS code, they would just get empty chunks, bc `result.code` is `undefined` - that's kind of buggy, it should probably either be forced to `false` or do what we're doing now, which is likely more intuitive / intended - so now, instead of getting an empty chunk, rpt2 will just pass to the next plugin, allowing for other plugins on the chain to process TS - this opens up some new use cases, like using in tandem with Babel plugins (as the issue illustrates) or using for type-checking and declaration generation while using Vite / ESBuild for compilation - add a new paragraph to "Declarations" docs about this new feature and what it does and some examples of how it could be used - note that these are unexplored / untested integrations, so point that out in the docs too - also modify a self-reference further up in the docs to use code backticks for `rollup-plugin-typescript2` - while at it, also add a line about declaration maps - and reformat the existing paragraph a bit to match the style and improve readability - one sentence per line, which is all on the same paragraph in Markdown anyway - add a `<br />` element to add a new-line _within_ the paragraph for better readability / spacing - Markdown supports this only with two trailing spaces, which is difficult to see and the trailing whitespace can be trimmed by editors, so prefer `<br />`
- Loading branch information