gulp-typescript icon indicating copy to clipboard operation
gulp-typescript copied to clipboard

Support --incremental builds by emitting .buildinfo

Open michaelaird opened this issue 6 years ago • 19 comments

Typescript 3.4 introduces emitting .tsbuildinfo files that are used for --incremental builds outside of --watch: https://devblogs.microsoft.com/typescript/announcing-typescript-3-4-rc/

gulp-typescript should emit the appropriate .tsbuildinfo files.

michaelaird avatar Mar 17 '19 22:03 michaelaird

NB: unfortunately, setting "incremental", either in tsconfig.json or in the call to gulp-typescript, doesn't work.

jeffrson avatar Apr 02 '19 07:04 jeffrson

This may need to wait for typescript to provide an API https://github.com/Microsoft/TypeScript/issues/29978

adriangodong avatar Apr 05 '19 04:04 adriangodong

If you want to use typescript 3.4 with gulp-typescript on composite builds, then you can trick typescript into not tripping up by explicitly setting tsBuildInfoFile:

        "tsBuildInfoFile": "./buildcache/tsBuildInfo",

I needed to find a way for us as we'd like to keep in step on language features and we can now use incremental in our dev build.

nealeu avatar Apr 10 '19 10:04 nealeu

If you want to use typescript 3.4 with gulp-typescript on composite builds, then you can trick typescript into not tripping up by explicitly setting tsBuildInfoFile:

        "tsBuildInfoFile": "./buildcache/tsBuildInfo",

I needed to find a way for us as we'd like to keep in step on language features and we can now use incremental in our dev build.

Unfotunately this didn't work for us. There is still no ".tsBuildInfo"

mzyil avatar Apr 11 '19 13:04 mzyil

@mzyil

You won't be able to get that until this issue is resolve which depends on API support.

We're using tsc --build for our developer build and then gulp-typescript for our production bundle.

nealeu avatar Apr 12 '19 11:04 nealeu

The Typescript issue is now closed: https://github.com/microsoft/TypeScript/issues/29978 Any plans to work on this?

mzyil avatar Jun 06 '19 21:06 mzyil

Having support for the --incremental flag would be great.

arieldf avatar Jun 07 '19 17:06 arieldf

Great news that TypeScript now exposes this in an API. I personally won't have time to work on this in the following weeks. If someone wants to work on this, let me know and I'd be happy to give some guidance.

I'm not that familiar with the tsc --build option. For incremental compilation, it seems like we must use createIncrementalProgram instead of createProgram. For the first compilation we need to pass that function the build information from the .buildinfo file which we get using readBuilderProgram. For further incremental compilations, we just need to pass it the old Program just like we're already doing.

ivogabe avatar Jun 08 '19 19:06 ivogabe

I took a first crack at emitting .buildinfo files (https://github.com/ivogabe/gulp-typescript/pull/618) . This might be enough?

michaelaird avatar Jun 16 '19 14:06 michaelaird

@michaelaird does your PR enable the incremental builds only if the option in tsconfig.json is set?

 "tsBuildInfoFile": "./buildcache/tsBuildInfo",

or do we need to change something else in the stream?

mzyil avatar Jun 16 '19 15:06 mzyil

If the .buildinfo file is created by tsc ( because the composite option or incremental option is true) the buildinfo file will be available on result.buildInfo.

It’s possible we might want to always emit this alongside the js and not need another stream.

On Sun, Jun 16, 2019 at 11:09 AM Melih Yıldız [email protected] wrote:

@michaelaird https://github.com/michaelaird does your PR enable the incremental builds only if the option in tsconfig.json is set?

"tsBuildInfoFile": "./buildcache/tsBuildInfo",

or do we need to change something else in the stream?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/ivogabe/gulp-typescript/issues/611?email_source=notifications&email_token=AABVP2OBYS5FL3UBE4QCLSDP2ZJTLA5CNFSM4G7CYPL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXZPBYQ#issuecomment-502460642, or mute the thread https://github.com/notifications/unsubscribe-auth/AABVP2PURJ2QINICUIXN7TTP2ZJTLANCNFSM4G7CYPLQ .

michaelaird avatar Jun 16 '19 15:06 michaelaird

Any workaround available? It takes like 5 seconds to build all my scripts, and it takes milliseconds when in incremental mode.

pronebird avatar Aug 26 '19 15:08 pronebird

It's entirely possible that my changes targeting 3.4/3.5 are entirely useless with 3.6 and the correct approach is to tie into the the new apis to support incremental builds (https://github.com/microsoft/TypeScript/issues/31849) , ie createIncrementalCompilerHost and createIncrementalProgram.

michaelaird avatar Sep 13 '19 16:09 michaelaird

That’s a good point, I’ll try to make some time for it this weekend

ivogabe avatar Sep 13 '19 17:09 ivogabe

any updates on this?

mzyil avatar Sep 20 '19 15:09 mzyil

There were some issues with the tests, after upgrading TypeScript. I don’t get them locally, so it may be OS related.

The tsbuildinfo file can currently crash the compiler, so I was preparing a temporary fix which would just ignore the tsbuildinfo file, and then later implement the new incremental apis. I’ll continue with it in this weekend

ivogabe avatar Sep 20 '19 16:09 ivogabe

@ivogabe Thank you! Please let me know if i can help.

michaelaird avatar Sep 20 '19 16:09 michaelaird

Any updates on this?

bgedik avatar Oct 04 '19 14:10 bgedik

Work-in-progress PR in #635. Some functionalities of the new API are not clear to me yet, I hope to get more information on that soon.

ivogabe avatar Nov 17 '19 21:11 ivogabe