feat(typescript): allow override of forced noEmit
and emitDeclarationOnly
compiler options
#1242
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rollup Plugin Name:
typescript
This PR contains:
Are tests included?
Breaking Changes?
If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.
List any relevant issue numbers:
Description
This MR is a replacement for the closed #1206. the suggested feature of a
transpilerMode
option, which unfortunately was discovered to be a breaking change.Why
Currently, this plugin forced the
compilerOptions
noEmit
andemitDeclarationOnly
to be false. There is a note// Typescript needs to emit the code for us to work with.
This is false
The way that the plugin is written, the
load
hook looks for if typescript did transpilation for a file and returns that if found, null otherwise. This means foremitDeclarationOnly
rollup will simply load from the output of the previous plugin or from the file system. This is ideal to mimic the following:Where build uses babel to do all transpilation, including typescript via
@babel/preset-typescript
, andtsc
is used to only emit declaration files.Currently, rollup can more or less do this by running all code though
@rollup/plugin-typescript
first and then@rollup/plugin-babel
, however with the forcedemitDeclarationOnly: false
being on, all the code is run through thetypescript
transpiler first. If@rollup/plugin-babel
is set up to do totypescript
, there isn't a need to actually do thisBy allowing
emitDeclarationOnly: true
,@rollup/plugin-typescript
is drastically faster! Since it only has to emit declaration file (which are emitted by rollup separately as "asset" files in the generateBundle step). On the large projects I tested this out at my work, I say initial builds drop from 20 seconds down to 2 seconds