When ngcc is called for a specific entry-point, it has to determine which dependencies to transitively process. To accomplish this, ngcc traverses the full import graph of the entry-points it encounters, for which it uses a dependency host to find all module imports. Since imports look different in the various bundle formats ngcc supports, a specific dependency host is used depending on the information provided in an entry-points `package.json` file. If there's not enough information in the `package.json` file for ngcc to be able to determine which dependency host to use, ngcc would fail with an error. If, however, the entry-point is not compiled by Angular, it is not necessary to process any of its dependencies. None of them can have been compiled by Angular so ngcc does not need to know about them. Therefore, this commit changes the behavior to avoid recursing into dependencies of entry-points that are not compiled by Angular. In particular, this fixes an issue for packages that have dependencies on the `date-fns` package. This package has various secondary entry-points that have a `package.json` file only containing a `typings` field, without providing additional fields for ngcc to know which dependency host to use. By not needing a dependency host at all, the error is avoided. Fixes #32302 PR Close #32303
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