question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support Typescript incremental build

See original GitHub issue

πŸš€ Feature request

- [ ] new
- [x] build
- [x] serve
- [x] test
- [x] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Description

Support of Typescript incremental build https://devblogs.microsoft.com/typescript/announcing-typescript-3-4-rc/

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:130
  • Comments:52 (34 by maintainers)

github_iconTop GitHub Comments

34reactions
alan-agius4commented, May 9, 2021

Transfering to the FW repo as the compiler doesn’t support TypeScript incremental API.

Example it uses ts.createProgram, instead of ts.createIncrementalProgram with the latter is require to use the tsbuild info.

I did experiment a bit using the NGTSC plugin API with allows for a program to be supplied and patching on a small project https://github.com/ngrx/platform/tree/master/modules/component/src I saw the compilation to go from 5s to 2.5s.


const host = ts.createIncrementalCompilerHost(compilerOptions);
const wrappedHost = ngtsc.wrapHost(host, config.rootNames, compilerOptions)

const program = ts.createIncrementalProgram({
  options: compilerOptions,
  rootNames: config.rootNames,
  host: wrappedHost,
  createProgram: ts.createEmitAndSemanticDiagnosticsBuilderProgram
})

const { ignoreForEmit } = ngtsc.setupCompilation(program.getProgram(), undefined);

NB: NGTSC would also need to set versions to typechecking source files.

27reactions
filipesilvacommented, Sep 23, 2019

I should set expectations regarding the potential usefulness of supporting TS’s --incremental functionality right now. As a recap, this functionality from TS allows a typescript compilation to reuse artifacts from a previous compilation in order to be faster. This doesn’t apply to watch mode. It only applies to whole new compilations (e.g. calling the command from the console again).

In an Angular CLI context this would mean that some calls to ng build, ng serve and ng test might be faster after the first call. Ideally you’d want your slowest builds, usually the production builds, to get faster by using this new typescript functionality. But there are a lot of caveats here.

First and foremost is that the typescript compilation is only one part of building an app, and not necessarily what takes longer. Then there’s the fact that AOT compilation is not just a Typescript compilation, there’s many other things happening there that have nothing to do with compiling TS. Another thing to take into consideration is that CI builds wouldn’t use this either unless you were very careful in managing the TS cache.

Realistically, this means that production builds wouldn’t see any improvement because they use AOT and a big chunk of the time is spent in bundle optimization. JIT development builds are what would benefit from TS’s --incremental functionality. But with Ivy it’s already preferable to develop in AOT, so no benefit again.

I feel this feature looks very desirable because it sounds like it would make all builds much faster. But the reality is that it would make some of the faster builds a bit faster, while the others would remain the same. Notably rebuilds on watch mode are entirely unaffected, because this functionality isn’t related to watch mode.

Read more comments on GitHub >

github_iconTop Results From Across the Web

incremental - TSConfig Option - TypeScript
TSConfig. incremental ... How to create and type JavaScript variables. TypeScript in 5 minutes. An overview of building a TypeScript web app.
Read more >
Incremental compilation with TypeScript while using --noEmit?
Is there a way I can run tsc --incremental --noEmit , actually incrementally compile, and only generate the tsconfig.tsbuildinfo file needed forΒ ...
Read more >
Typescript: incremental builds - YouTube
Typescript incremental builds is a new feature in typescript version 3.4. With this feature we can increase the build time,Β ...
Read more >
Upgrading To Typescript 3.5 And Incremental Builds
Upgrading To Typescript 3.5 And Incremental Builds Β· Background. TypeScript 3.4 added a new compiler option I was very excited about: theΒ ...
Read more >
incremental-typescript - npm
Incremental TypeScript compiler. Latest version: 3.3.1-1, last published: 4 years ago. Start using incremental-typescript in your project byΒ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found