2

I would like to do the same, as I could in the good old tsc times: simply calling a tsc -w, and in the case of a changed file, it will be on the fly recompilated.

Unfortunately, ngc doesn't even seem to react anything to the -w flag, and even its possible command line arguments are completely undocumented.

But, ng build has a --watch flag, while it can create also AOT builds. Thus, probably a watch-mode ngc is possible.

But how?

peterh
  • 11,875
  • 18
  • 85
  • 108
  • I believe AOT compiler (ngc) doesn't support watch mode yet – Max Koretskyi Jun 07 '17 at 15:22
  • @Maximus Ok, but why angular-cli still supports it, while it supports also aot? – peterh Jun 07 '17 at 15:41
  • I don't know. The recent talk I watched by Tobias about future plans included supporting watch mode for `ngc`, hence it doesn't support it now – Max Koretskyi Jun 07 '17 at 15:48
  • @Maximus Could you please insert a link to this talk as an answer converted from your comment? I would be happy to upvote/accept it. Thanks! – peterh Jun 07 '17 at 16:12
  • sure, done, thanks. I've recently written [an article](https://hackernoon.com/here-is-what-you-need-to-know-about-dynamic-components-in-angular-ac1e96167f9e) that touches upon a compiler a bit. Might be of interest to you – Max Koretskyi Jun 07 '17 at 16:18

2 Answers2

1

Version 5:

You can now use watch mode like this:

ngc -w

See this comment by Tobias:

The command line ngc also has a -w option now that watches the file system and we see speedups for subsequent builds of up to 10x, as we have some logic in place to only compile components in node_modules 1x.

Version prior to 4

At the moment ngc doesn't support watch mode. It's addition identified by the Tobias Bosch as priority features. Here is the video where he talks about that.

Max Koretskyi
  • 101,079
  • 60
  • 333
  • 488
1

The changelog of Angular 5 states that ngc watch is now a thing! https://github.com/angular/angular/blob/master/CHANGELOG.md#500-pentagonal-donut-2017-11-01

Features: compiler-cli: add watch mode to ngc (#18818) (06d01b2)

kair
  • 946
  • 1
  • 10
  • 16