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:

committed by
Matias Niemelä

parent
50710838bf
commit
de445709d4
@ -460,7 +460,7 @@ export class NgtscProgram implements api.Program {
|
||||
// Finally, check if the reference is being written into a file within the project's logical
|
||||
// file system, and use a relative import if so. If this fails, ReferenceEmitter will throw
|
||||
// an error.
|
||||
new LogicalProjectStrategy(checker, new LogicalFileSystem(this.rootDirs)),
|
||||
new LogicalProjectStrategy(this.reflector, new LogicalFileSystem(this.rootDirs)),
|
||||
]);
|
||||
} else {
|
||||
// The CompilerHost supports fileNameToModuleName, so use that to emit imports.
|
||||
@ -470,7 +470,7 @@ export class NgtscProgram implements api.Program {
|
||||
// Then use aliased references (this is a workaround to StrictDeps checks).
|
||||
new AliasStrategy(),
|
||||
// Then use fileNameToModuleName to emit imports.
|
||||
new FileToModuleStrategy(checker, this.fileToModuleHost),
|
||||
new FileToModuleStrategy(this.reflector, this.fileToModuleHost),
|
||||
]);
|
||||
aliasGenerator = new AliasGenerator(this.fileToModuleHost);
|
||||
}
|
||||
|
Reference in New Issue
Block a user