feat(ivy): exclude declarations from injector imports (#29598)
Prior to this change, a module's imports and exports would be used verbatim as an injectors' imports. This is detrimental for tree-shaking, as a module's exports could reference declarations that would then prevent such declarations from being eligible for tree-shaking. Since an injector actually only needs NgModule references as its imports, we may safely filter out any declarations from the list of module exports. This makes them eligible for tree-shaking once again. PR Close #29598
This commit is contained in:
@ -110,8 +110,8 @@ export interface R3InjectorMetadataFacade {
|
||||
name: string;
|
||||
type: any;
|
||||
deps: R3DependencyMetadataFacade[]|null;
|
||||
providers: any;
|
||||
imports: any;
|
||||
providers: any[];
|
||||
imports: any[];
|
||||
}
|
||||
|
||||
export interface R3DirectiveMetadataFacade {
|
||||
|
@ -73,7 +73,7 @@ export class CompilerFacadeImpl implements CompilerFacade {
|
||||
type: new WrappedNodeExpr(facade.type),
|
||||
deps: convertR3DependencyMetadataArray(facade.deps),
|
||||
providers: new WrappedNodeExpr(facade.providers),
|
||||
imports: new WrappedNodeExpr(facade.imports),
|
||||
imports: facade.imports.map(i => new WrappedNodeExpr(i)),
|
||||
};
|
||||
const res = compileInjector(meta);
|
||||
return this.jitExpression(res.expression, angularCoreEnv, sourceMapUrl, res.statements);
|
||||
|
@ -191,7 +191,7 @@ export interface R3InjectorMetadata {
|
||||
type: o.Expression;
|
||||
deps: R3DependencyMetadata[]|null;
|
||||
providers: o.Expression;
|
||||
imports: o.Expression;
|
||||
imports: o.Expression[];
|
||||
}
|
||||
|
||||
export function compileInjector(meta: R3InjectorMetadata): R3InjectorDef {
|
||||
@ -204,7 +204,7 @@ export function compileInjector(meta: R3InjectorMetadata): R3InjectorDef {
|
||||
const expression = o.importExpr(R3.defineInjector).callFn([mapToMapExpression({
|
||||
factory: result.factory,
|
||||
providers: meta.providers,
|
||||
imports: meta.imports,
|
||||
imports: o.literalArr(meta.imports),
|
||||
})]);
|
||||
const type =
|
||||
new o.ExpressionType(o.importExpr(R3.InjectorDef, [new o.ExpressionType(meta.type)]));
|
||||
|
Reference in New Issue
Block a user