fix(ivy): use ReflectionHost to check exports when writing an import (#33192)

This commit fixes ngtsc's import generator to use the ReflectionHost when
looking through the exports of an ES module to find the export of a
particular declaration that's being imported. This is necessary because
some module formats like CommonJS have unusual export mechanics, and the
normal TypeScript ts.TypeChecker does not understand them.

This fixes an issue with ngcc + CommonJS where exports were not being
enumerated correctly.

FW-1630 #resolve

PR Close #33192
This commit is contained in:
Alex Rickabaugh
2019-10-02 10:54:23 +03:00
committed by Matias Niemelä
parent 50710838bf
commit de445709d4
9 changed files with 95 additions and 23 deletions

View File

@ -59,7 +59,7 @@ export class DecorationAnalyzer {
// TODO(alxhub): there's no reason why ngcc needs the "logical file system" logic here, as ngcc
// projects only ever have one rootDir. Instead, ngcc should just switch its emitted import
// based on whether a bestGuessOwningModule is present in the Reference.
new LogicalProjectStrategy(this.typeChecker, new LogicalFileSystem(this.rootDirs)),
new LogicalProjectStrategy(this.reflectionHost, new LogicalFileSystem(this.rootDirs)),
]);
dtsModuleScopeResolver =
new MetadataDtsModuleScopeResolver(this.dtsMetaReader, /* aliasGenerator */ null);