angular-cn/packages/compiler-cli/ngcc
George Kalpakas ca25c957bf fix(ngcc): correctly detect imported TypeScript helpers (#36284)
The `NgccReflectionHost`s have logic for detecting certain known
declarations (such as `Object.assign()` and TypeScript helpers), which
allows the `PartialEvaluator` to evaluate expressions it would not be
able to statically evaluate otherwise.

In #36089, `DelegatingReflectionHost` was introduced, which delegates to
a TypeScript `ReflectionHost` when reflecting on TypeScript files, which
for ngcc's case means `.d.ts` files of dependencies. As a result, ngcc
lost the ability to detect TypeScript helpers imported from `tslib`,
because `DelegatingReflectionHost` was not able to apply the known
declaration detection logic while reflecting on `tslib`'s `.d.ts` files.

This commit fixes this by ensuring `DelegatingReflectionHost` calls the
`NgccReflectionHost`'s `detectKnownDeclaration()` method as necessary,
even when using the TypeScript `ReflectionHost`.

NOTE:
The previous commit exposed a bug in ngcc that was hidden due to the
tests' being inconsistent with how the `ReflectionHost`s are used in the
actual program. The changes in this commit are verified by ensuring the
failing tests are now passing (hence no new tests are added).

PR Close #36284
2020-04-03 11:08:46 -07:00
..
src fix(ngcc): correctly detect imported TypeScript helpers (#36284) 2020-04-03 11:08:46 -07:00
test test(ngcc): use `DelegatingReflectionHost` for testing `NgccReflectionHost`s (#36284) 2020-04-03 11:08:46 -07:00
BUILD.bazel fix(ngcc): use path-mappings from tsconfig in dependency resolution (#36180) 2020-03-24 10:16:12 -07:00
README.md refactor(ivy): move ngcc into a higher level folder (#29092) 2019-03-20 14:45:54 -04:00
index.ts refactor(ngcc): expose logging level on the logger (#35861) 2020-03-05 18:17:15 -05:00
main-ivy-ngcc.ts fix(ngcc): rename the executable from `ivy-ngcc` to `ngcc` (#33140) 2019-10-14 16:29:14 +00:00
main-ngcc.ts fix(ngcc): use path-mappings from tsconfig in dependency resolution (#36180) 2020-03-24 10:16:12 -07:00

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