
In #34288, ngtsc was refactored to separate the result of the analysis and resolve phase for more granular incremental rebuilds. In this model, any errors in one phase transition the trait into an error state, which prevents it from being ran through subsequent phases. The ngcc compiler on the other hand did not adopt this strict error model, which would cause incomplete metadata—due to errors in earlier phases—to be offered for compilation that could result in a hard crash. This commit updates ngcc to take advantage of ngtsc's `TraitCompiler`, that internally manages all Ivy classes that are part of the compilation. This effectively replaces ngcc's own `AnalyzedFile` and `AnalyzedClass` types, together with all of the logic to drive the `DecoratorHandler`s. All of this is now handled in the `TraitCompiler`, benefiting from its explicit state transitions of `Trait`s so that the ngcc crash is a thing of the past. Fixes #34500 Resolves FW-1788 PR Close #34889
ngcc migrations
There are some cases where source code needs to be migrated before ngtsc can compile it correctly.
For example, there are cases where ngtsc expects directives need to be explicitly attached to classes, whereas previously they were not required.
There are two ways this can happen:
- in a project being developed, the code can be migrated via a CLI schematic.
- in a package already published to npm, the code can be migrated as part of the ngcc compilation.
To create one of these migrations for ngcc, you should implement the Migration
interface and add
an instance of the class to the DecorationAnalyzer.migrations
collection.
This folder is where we keep the Migration
interface and the implemented migrations.
Each migration should have a unit test stored in the ../../test/migrations
directory.