fix(ngcc): do not attempt compilation when analysis fails (#34889)
In #34288, ngtsc was refactored to separate the result of the analysis and resolve phase for more granular incremental rebuilds. In this model, any errors in one phase transition the trait into an error state, which prevents it from being ran through subsequent phases. The ngcc compiler on the other hand did not adopt this strict error model, which would cause incomplete metadata—due to errors in earlier phases—to be offered for compilation that could result in a hard crash. This commit updates ngcc to take advantage of ngtsc's `TraitCompiler`, that internally manages all Ivy classes that are part of the compilation. This effectively replaces ngcc's own `AnalyzedFile` and `AnalyzedClass` types, together with all of the logic to drive the `DecoratorHandler`s. All of this is now handled in the `TraitCompiler`, benefiting from its explicit state transitions of `Trait`s so that the ngcc crash is a thing of the past. Fixes #34500 Resolves FW-1788 PR Close #34889
This commit is contained in:
@ -124,6 +124,7 @@ export class DtsRenderer {
|
||||
|
||||
// Capture the rendering info from the decoration analyses
|
||||
decorationAnalyses.forEach(compiledFile => {
|
||||
let appliedReexports = false;
|
||||
compiledFile.compiledClasses.forEach(compiledClass => {
|
||||
const dtsDeclaration = this.host.getDtsDeclaration(compiledClass.declaration);
|
||||
if (dtsDeclaration) {
|
||||
@ -135,9 +136,11 @@ export class DtsRenderer {
|
||||
// to work, the typing file and JS file must be in parallel trees. This logic will detect
|
||||
// the simplest version of this case, which is sufficient to handle most commonjs
|
||||
// libraries.
|
||||
if (compiledClass.declaration.getSourceFile().fileName ===
|
||||
dtsFile.fileName.replace(/\.d\.ts$/, '.js')) {
|
||||
renderInfo.reexports.push(...compiledClass.reexports);
|
||||
if (!appliedReexports &&
|
||||
compiledClass.declaration.getSourceFile().fileName ===
|
||||
dtsFile.fileName.replace(/\.d\.ts$/, '.js')) {
|
||||
renderInfo.reexports.push(...compiledFile.reexports);
|
||||
appliedReexports = true;
|
||||
}
|
||||
dtsMap.set(dtsFile, renderInfo);
|
||||
}
|
||||
|
@ -88,13 +88,13 @@ export class Renderer {
|
||||
const renderedStatements =
|
||||
this.renderAdjacentStatements(compiledFile.sourceFile, clazz, importManager);
|
||||
this.srcFormatter.addAdjacentStatements(outputText, clazz, renderedStatements);
|
||||
|
||||
if (!isEntryPoint && clazz.reexports.length > 0) {
|
||||
this.srcFormatter.addDirectExports(
|
||||
outputText, clazz.reexports, importManager, compiledFile.sourceFile);
|
||||
}
|
||||
});
|
||||
|
||||
if (!isEntryPoint && compiledFile.reexports.length > 0) {
|
||||
this.srcFormatter.addDirectExports(
|
||||
outputText, compiledFile.reexports, importManager, compiledFile.sourceFile);
|
||||
}
|
||||
|
||||
this.srcFormatter.addConstants(
|
||||
outputText,
|
||||
renderConstantPool(
|
||||
|
Reference in New Issue
Block a user