cf37c003ff
Angular View Engine uses global knowledge to compile the following code: ```typescript export class Base { constructor(private vcr: ViewContainerRef) {} } @Directive({...}) export class Dir extends Base { // constructor inherited from base } ``` Here, `Dir` extends `Base` and inherits its constructor. To create a `Dir` the arguments to this inherited constructor must be obtained via dependency injection. View Engine is able to generate a correct factory for `Dir` to do this because via metadata it knows the arguments of `Base`'s constructor, even if `Base` is declared in a different library. In Ivy, DI is entirely a runtime concept. Currently `Dir` is compiled with an ngDirectiveDef field that delegates its factory to `getInheritedFactory`. This looks for some kind of factory function on `Base`, which comes up empty. This case looks identical to an inheritance chain with no constructors, which works today in Ivy. Both of these cases will now become an error in this commit. If a decorated class inherits from an undecorated base class, a diagnostic is produced informing the user of the need to either explicitly declare a constructor or to decorate the base class. PR Close #34460 |
||
---|---|---|
.. | ||
src | ||
test | ||
BUILD.bazel | ||
README.md | ||
index.ts | ||
main-ivy-ngcc.ts | ||
main-ngcc.ts |
README.md
Angular Compatibility Compiler (ngcc)
This compiler will convert node_modules
compiled with ngc
, into node_modules
which
appear to have been compiled with ngtsc
.
This conversion will allow such "legacy" packages to be used by the Ivy rendering engine.
Building
The project is built using Bazel:
yarn bazel build //packages/compiler-cli/ngcc
Unit Testing
The unit tests are built and run using Bazel:
yarn bazel test //packages/compiler-cli/ngcc/test
Integration Testing
There are tests that check the behavior of the overall executable:
yarn bazel test //packages/compiler-cli/ngcc/test:integration