-
Notifications
You must be signed in to change notification settings - Fork 26.3k
feat(compiler-cli): add experimental support for fast type declaration emission #61334
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
feat(compiler-cli): add experimental support for fast type declaration emission #61334
Conversation
Questions for reviewers:
|
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.
LGTM, very clean 🎉 — left some minor nits/questions
packages/compiler-cli/test/compliance/declaration/declaration_compile_spec.ts
Outdated
Show resolved
Hide resolved
packages/compiler-cli/test/compliance/test_helpers/check_type_declarations.ts
Show resolved
Hide resolved
packages/compiler-cli/test/compliance/declaration/declaration_compile_spec.ts
Outdated
Show resolved
Hide resolved
packages/compiler-cli/test/ngtsc/declaration_compilation_spec.ts
Outdated
Show resolved
Hide resolved
packages/compiler-cli/test/compliance/test_cases/test_case_schema.json
Outdated
Show resolved
Hide resolved
@jonathan-meier Re your questions: The flag usage of For the error codes. I think you're fine in general, but one thing to keep in mind is that some local compilation diagnostics trigger this logic in 1P: http://shortn/_ejJkrvNkin |
f2cde4b
to
1f23a3e
Compare
…n emission In declaration-only emission mode, the compiler extracts the type declarations (.d.ts) files without full type-checking, which is possible with sufficient type annotations on exports that can be ensured by the `isolatedDeclarations` TS compiler option. This allows us to decouple type declaration emission from the actual full compilation doing the type-checking, thereby removing the edge between dependent TS files in the build action graph. In other words, the compilation of a TS file no longer indirectly depends on the compilation of all the TS files it imports through its dependency on their type declarations, because the type declarations themselves no longer depend on the compilation of their associated TS file. Without the coupling between type declaration emission and compilation, compilation time of a TS project is no longer bound dependent on the depth of the TS dependency tree as we can now build the entire project with just two entirely parallel phases: 1) emit the type declarations of all TS files in parallel and 2) compile all TS files in parallel. Since the Angular compiler adds static metadata fields to components, directives, modules, pipes and services based on their respective class annotations, it needs to actively partake in the type declaration emission in order to provide the types for these static fields in the declaration. In this change, we add experimental support for a declaration-only emission mode based on the local compilation mode, which already operates without type-checking and access to external type information, i.e. the same environment as is required for declaration-only emisssion. Apart from the same restrictions applied in local compilation mode, there are a few more restrictions imposed on code being compatible with this initial and experimental implementation: * No support for `@NgModule`s using external references. * No support for `hostDirectives` in `@Component`s and `@Directive`s using external references * No support for `@Input` annotations with `transform`.
1f23a3e
to
0aeceb1
Compare
Thanks for the pointer about using local compilation diagnostics in 1P! I'll keep reusing the error codes for now as I plan to support host directives in a follow-up which would remove the one instance using a local compilation error code. |
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.
LGTM
Reviewed-for: global-dev-infra-approvers
* The mode is experimental and specifically tailored to support fast type declaration emission | ||
* for the Gemini app in g3. | ||
*/ | ||
_geminiAllowEmitDeclarationOnly?: boolean; |
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'd propose renaming this config option (making it more geenric) for a couple of reasons:
- That should avoid any confusion that the option represents a special capability for Gemini LLM itself.
- If there is a desire or a need to test this behavior in other applications as a part of the experiment, it'd be confusing to use the current name.
* The mode is experimental and specifically tailored to support fast type declaration emission | |
* for the Gemini app in g3. | |
*/ | |
_geminiAllowEmitDeclarationOnly?: boolean; | |
* The mode is experimental and specifically tailored to support fast type declaration emission | |
* for the Gemini app in g3 for the initial phase of the experiment. | |
*/ | |
_experimentalAllowEmitDeclarationOnly?: boolean; |
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.
Note: since the PR has the "merge" label, please do not treat this comment as blocking. We can do a followup PR with an update if needed.
Caretaker note: we've discussed this with Jonathan and the proposed plan forward is to merge the PR as is and create a followup PR with the config option rename. |
Caretaker note #2: the presubmit is "green" after rerunning some targets, this PR is ready for merge. |
This PR was merged into the repository by commit e62fb35. The changes were merged into the following branches: main |
…ssion Rename the flag `_geminiAllowEmitDeclarationOnly` to `_experimentalAllowEmitDeclarationOnly` as a follow-up on a comment in PR angular#61334.
…ssion Rename the flag `_geminiAllowEmitDeclarationOnly` to `_experimentalAllowEmitDeclarationOnly` as a follow-up on a comment in PR angular#61334.
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. |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
No support for fast type declaration emission. Compilation fails with
emitDeclarationOnly
andnoCheck
TS compiler options set because the Angular compiler requires full type-checking information available for compilation.What is the new behavior?
In declaration-only emission mode, the compiler extracts the type declarations (.d.ts) files without full type-checking, which is possible with sufficient type annotations on exports that can be ensured by the
isolatedDeclarations
TS compiler option.This allows us to decouple type declaration emission from the actual full compilation doing the type-checking, thereby removing the edge between dependent TS files in the build action graph. In other words, the compilation of a TS file no longer indirectly depends on the compilation of all the TS files it imports through its dependency on their type declarations, because the type declarations themselves no longer depend on the compilation of their associated TS file.
Without the coupling between type declaration emission and compilation, compilation time of a TS project is no longer bound dependent on the depth of the TS dependency tree as we can now build the entire project with just two entirely parallel phases: 1) emit the type declarations of all TS files in parallel and 2) compile all TS files in parallel.
Since the Angular compiler adds static metadata fields to components, directives, modules, pipes and services based on their respective class annotations, it needs to actively partake in the type declaration emission in order to provide the types for these static fields in the declaration.
In this change, we add experimental support for a declaration-only emission mode based on the local compilation mode, which already operates without type-checking and access to external type information, i.e. the same environment as is required for declaration-only emisssion.
Apart from the same restrictions applied in local compilation mode, there are a few more restrictions imposed on code being compatible with this initial and experimental implementation:
@NgModule
s using external references.hostDirectives
in@Component
s and@Directive
s using external references.@Input
annotations withtransform
.Does this PR introduce a breaking change?
Other information
Internal references: