feat(ivy): generate .ngfactory stubs if requested (#25176)
Existing bootstrap code in the wild depends on the existence of .ngfactory files, which Ivy does not need. This commit adds the capability in ngtsc to generate .ngfactory files which bridge existing bootstrap code with Ivy. This is an initial step. Remaining work includes complying with the compiler option to specify a generated file directory, as well as presumably testing in g3. PR Close #25176
This commit is contained in:

committed by
Kara Erickson

parent
728d98d3a9
commit
0822dc70f2
@ -57,6 +57,7 @@ export interface DecoratorHandler<A> {
|
||||
export interface AnalysisOutput<A> {
|
||||
analysis?: A;
|
||||
diagnostics?: ts.Diagnostic[];
|
||||
factorySymbolName?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,6 +37,10 @@ export class IvyCompilation {
|
||||
*/
|
||||
private analysis = new Map<ts.Declaration, EmitFieldOperation<any>>();
|
||||
|
||||
/**
|
||||
* Tracks factory information which needs to be generated.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tracks the `DtsFileTransformer`s for each TS file that needs .d.ts transformations.
|
||||
*/
|
||||
@ -55,7 +59,8 @@ export class IvyCompilation {
|
||||
*/
|
||||
constructor(
|
||||
private handlers: DecoratorHandler<any>[], private checker: ts.TypeChecker,
|
||||
private reflector: ReflectionHost, private coreImportsFrom: ts.SourceFile|null) {}
|
||||
private reflector: ReflectionHost, private coreImportsFrom: ts.SourceFile|null,
|
||||
private sourceToFactorySymbols: Map<string, Set<string>>|null) {}
|
||||
|
||||
|
||||
analyzeSync(sf: ts.SourceFile): void { return this.analyze(sf, false); }
|
||||
@ -105,6 +110,11 @@ export class IvyCompilation {
|
||||
if (analysis.diagnostics !== undefined) {
|
||||
this._diagnostics.push(...analysis.diagnostics);
|
||||
}
|
||||
|
||||
if (analysis.factorySymbolName !== undefined && this.sourceToFactorySymbols !== null &&
|
||||
this.sourceToFactorySymbols.has(sf.fileName)) {
|
||||
this.sourceToFactorySymbols.get(sf.fileName) !.add(analysis.factorySymbolName);
|
||||
}
|
||||
};
|
||||
|
||||
if (preanalyze && adapter.preanalyze !== undefined) {
|
||||
|
Reference in New Issue
Block a user