feat(ivy): produce and consume ES2015 re-exports for NgModule re-exports (#28852)
In certain configurations (such as the g3 repository) which have lots of small compilation units as well as strict dependency checking on generated code, ngtsc's default strategy of directly importing directives/pipes into components will not work. To handle these cases, an additional mode is introduced, and is enabled when using the FileToModuleHost provided by such compilation environments. In this mode, when ngtsc encounters an NgModule which re-exports another from a different file, it will re-export all the directives it contains at the ES2015 level. The exports will have a predictable name based on the FileToModuleHost. For example, if the host says that a directive Foo is from the 'root/external/foo' module, ngtsc will add: ``` export {Foo as ɵng$root$external$foo$$Foo} from 'root/external/foo'; ``` Consumers of the re-exported directive will then import it via this path instead of directly from root/external/foo, preserving strict dependency semantics. PR Close #28852
This commit is contained in:

committed by
Ben Lesh

parent
15c065f9a0
commit
c1392ce618
@ -72,9 +72,10 @@ export class DecorationAnalyzer {
|
||||
// on whether a bestGuessOwningModule is present in the Reference.
|
||||
new LogicalProjectStrategy(this.typeChecker, new LogicalFileSystem(this.rootDirs)),
|
||||
]);
|
||||
dtsModuleScopeResolver =
|
||||
new MetadataDtsModuleScopeResolver(this.typeChecker, this.reflectionHost);
|
||||
scopeRegistry = new LocalModuleScopeRegistry(this.dtsModuleScopeResolver);
|
||||
dtsModuleScopeResolver = new MetadataDtsModuleScopeResolver(
|
||||
this.typeChecker, this.reflectionHost, /* aliasGenerator */ null);
|
||||
scopeRegistry = new LocalModuleScopeRegistry(
|
||||
this.dtsModuleScopeResolver, this.refEmitter, /* aliasGenerator */ null);
|
||||
evaluator = new PartialEvaluator(this.reflectionHost, this.typeChecker);
|
||||
moduleResolver = new ModuleResolver(this.program, this.options, this.host);
|
||||
importGraph = new ImportGraph(this.moduleResolver);
|
||||
|
Reference in New Issue
Block a user