feat(compiler): generate proper reexports in .ngfactory.ts
files to not need transitive deps for compiling .ngfactory.ts
files. (#13524)
Note: This checks the constructors of `@Injectable` classes more strictly. E.g this will fail now as the constructor argument has no `@Inject` nor is the type of the argument a DI token. ``` @Injectable() class MyService { constructor(dep: string) {} } ``` Last part of #12787 Closes #12787
This commit is contained in:
@ -19,9 +19,12 @@ import {LifecycleHooks} from './private_import_core';
|
||||
import {NgModuleProviderAnalyzer} from './provider_analyzer';
|
||||
import {ProviderAst} from './template_parser/template_ast';
|
||||
|
||||
/**
|
||||
* This is currently not read, but will probably be used in the future.
|
||||
* We keep it as we already pass it through all the rigth places...
|
||||
*/
|
||||
export class ComponentFactoryDependency {
|
||||
constructor(
|
||||
public comp: CompileIdentifierMetadata, public placeholder: CompileIdentifierMetadata) {}
|
||||
constructor(public compType: any) {}
|
||||
}
|
||||
|
||||
export class NgModuleCompileResult {
|
||||
@ -46,13 +49,12 @@ export class NgModuleCompiler {
|
||||
const bootstrapComponentFactories: CompileIdentifierMetadata[] = [];
|
||||
const entryComponentFactories =
|
||||
ngModuleMeta.transitiveModule.entryComponents.map((entryComponent) => {
|
||||
const id: CompileIdentifierMetadata = {reference: null};
|
||||
if (ngModuleMeta.bootstrapComponents.some(
|
||||
(id) => id.reference === entryComponent.reference)) {
|
||||
bootstrapComponentFactories.push(id);
|
||||
(id) => id.reference === entryComponent.componentType)) {
|
||||
bootstrapComponentFactories.push({reference: entryComponent.componentFactory});
|
||||
}
|
||||
deps.push(new ComponentFactoryDependency(entryComponent, id));
|
||||
return id;
|
||||
deps.push(new ComponentFactoryDependency(entryComponent.componentType));
|
||||
return {reference: entryComponent.componentFactory};
|
||||
});
|
||||
const builder = new _InjectorBuilder(
|
||||
ngModuleMeta, entryComponentFactories, bootstrapComponentFactories, sourceSpan);
|
||||
|
Reference in New Issue
Block a user