-
Notifications
You must be signed in to change notification settings - Fork 24.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ngcc): switch ngcc over to use the TraitCompiler
#34889
Conversation
This PR is a replacement for #34652, with a different approach. Instead of making use of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice refactoring! It is great to see so much code removed from ngcc.
Can you add the NgccTraitCompiler
spec and simplify the DefaultMigrationHost
spec as mentioned below.
Otherwise LGTM!
import {createComponentDecorator} from '../../src/migrations/utils'; | ||
import {EntryPointBundle} from '../../src/packages/entry_point_bundle'; | ||
import {MockLogger} from '../helpers/mock_logger'; | ||
import {makeTestEntryPointBundle} from '../helpers/utils'; | ||
|
||
runInEachFileSystem(() => { | ||
describe('DefaultMigrationHost', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me that most of this spec file is actually testing the NgccTraitCompiler
. The DefaultMigrationHost
mostly just delegates to that.
How about simplifying this spec just to check that the delegation occurs as expected, and then create a spec for NgccTraitCompiler
that exercises the tests here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm really not fond of testing just delegation behaviour, as doing so starts to be testing an implementation rather than some desired behaviour. I do see however where you're coming from here, and have moved most of the injectSyntheticDecorator
and getAllDecorators
tests to an NgccTraitCompiler
spec file, while retaining some in the DefaultMigrationHost
specs to test the logic in the context of the migration host.
This syntax is invalid in these source files and does result in compilation errors as the constructor parameters could not be resolved. This hasn't been an issue until now as those errors were ignored in the tests, but future work to introduce the Trait system of ngtsc into ngcc will cause these errors to prevent compilation, resulting in broken tests.
In angular#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 angular#34500 Resolves FW-1788
6342500
to
daa2f30
Compare
This is green on CI: angular/ngcc-validation#792 @petebacondarwin PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grand!
merge-assistence: Alex has approved on behalf of fw-compiler when it was still draft. |
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
…34889) This syntax is invalid in these source files and does result in compilation errors as the constructor parameters could not be resolved. This hasn't been an issue until now as those errors were ignored in the tests, but future work to introduce the Trait system of ngtsc into ngcc will cause these errors to prevent compilation, resulting in broken tests. PR Close #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
…ngular#34889) This syntax is invalid in these source files and does result in compilation errors as the constructor parameters could not be resolved. This hasn't been an issue until now as those errors were ignored in the tests, but future work to introduce the Trait system of ngtsc into ngcc will cause these errors to prevent compilation, resulting in broken tests. PR Close angular#34889
) In angular#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 angular#34500 Resolves FW-1788 PR Close angular#34889
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
fix(ngcc): do not attempt compilation when analysis fails
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
andAnalyzedClass
types, together with all of the logic to drive theDecoratorHandler
s. All of this is now handled in theTraitCompiler
,benefiting from its explicit state transitions of
Trait
s so that thengcc crash is a thing of the past.
Fixes #34500
Resolves FW-1788