5

When I currently run ng build command, I get a whole bunch of runtime issues that are absent when I compile in JIT mode (Angular 6).

Is there a way to get a list of all the AOT issues at compile time, without having to find them out manually?

I thought there was at least a package of tslint rules that would enforce the developers to write AOT-compliant code, but I can't find one. Am I missing something?

Any help appreciated.

UPDATE: One of the runtime issues I'm talking about is that mat-icons from Angular Material don't work. They just render as text, like "chevron_left". The bundle, obviously, does not contain the MatIconModule. However, everything works as expected with JIT.

Besides, when I read the AOT documentation, I see that AOT compiler does not support references to local (not exported) symbols. However, I do reference local symbols in my decorators, but I don't get any compilation errors notifying me about this.

Maksym
  • 458
  • 4
  • 23
  • You can't detect them like tslint because AOT errors are compilation errors. The app actually needs to be compiled. You need to compile AOT often to not get overwhelming heap of errors. A proper way to handle this is to set up CI to do AOT builds on every commit. – Estus Flask May 14 '18 at 19:06
  • @estus I do run the AOT compilation, but I don't get any comilation errors. However, when I view my app in the browser, I can clearly see that something is wrong with the comiled app. – Maksym May 14 '18 at 19:09
  • 1
    Can you elaborate in the question what kind these runtime issues are? Any way, I don't think that it's possible to do something, AOT compiler already shows all problems that can be detected at compile time. Those runtime issues can be absolutely anything, including framework bugs. A possible solution is to stick to CI and provide minimal test coverage, at least to the point you can figure out that some app units stopped working properly after specific commit. – Estus Flask May 14 '18 at 19:14
  • You can try writing tests to check your app on runtime, you will face these errors when you run the app. You could have a different environment, as an example, you can have two pages and when you navigate from A to B all is fine, but when you try to go directly to B from the navigation bar the app blow up, that could be because B needs a package that was loaded by A. – dlcardozo May 14 '18 at 19:24
  • @estus I've expanded my question as per your request, please take a look. – Maksym May 14 '18 at 19:52
  • *does not support references to local (not exported) symbols* - what are Angular and CLI versions? IIRC not limiting to exported references was in ongoing features. `chevron_left` - this could be because web fonts weren't loaded for some reason, are you sure that the problem is with MatIconModule itself? – Estus Flask May 14 '18 at 20:41
  • @estus Angular and cli are the 6.0.1 versions. The error is mentioned in the current Angular documentation: https://angular.io/guide/aot-compiler#reference-to-a-local-non-exported-symbol As per chevron_left, this seems to be a completely different bug: https://github.com/angular/angular-cli/issues/10855 But anyway, I'd expect `ng serve --aot` to show me all the compliance errors, rather than looking through the documentation to suddenly find out that my code may be actually incompatible with aot. – Maksym May 15 '18 at 12:21
  • 1
    It should give you errors. If it doesn't, feel free to open an issue in https://github.com/angular/angular-cli (there's a chance it will be a dupe, because such problem won't be unnoticed). A6 is still raw. As for me, I'm not that brave to use it yet. – Estus Flask May 15 '18 at 12:33

0 Answers0