Skip to content

feat(compiler-cli): run JIT transform on classes with jit: true opt-out - #56892

Closed
devversion wants to merge 3 commits into
angular:mainfrom
devversion:run-jit-transform
Closed

devversion wants to merge 3 commits into
angular:mainfrom
devversion:run-jit-transform

Conversation

@devversion

@devversion devversion commented Jul 8, 2024 •

Copy link
Copy Markdown
Member

Currently when compiling code with the Angular compiler, all classes
with Angular decorators are compiled with AOT. This includes type
checking, scope collection etc.

This may not be desirable for all components, e.g. dynamic components,
or test components w/ TestBed.configureTestingModule (if compiled with ngtsc).

Those components can opt out of AOT on a per component-basis via jit: true.
This is helpful as it allows incremental migrations/refactorings to AOT.
Whether we want to keep this capability long-term is something to be discussed separately.

For now though, we should fix that components compiled with jit: true
actually work as expected. Currently this not the case as soon as
the new initializer APIs are used— as those do no longer declare class
metadata with decorators.

This commit runs the JIT transform on JIT-opted classes.

@angular-robot angular-robot Bot added the detected: feature PR contains a feature commit label Jul 8, 2024
@devversion
devversion force-pushed the run-jit-transform branch 3 times, most recently from f17c64e to a053bd3 Compare July 8, 2024 13:37
@devversion devversion added action: review The PR is still awaiting reviews from at least one requested reviewer area: compiler Issues related to `ngc`, Angular's template compiler target: minor This PR is targeted for the next minor release labels Jul 8, 2024
@ngbot ngbot Bot modified the milestone: Backlog Jul 8, 2024
@devversion
devversion requested a review from crisbeto July 8, 2024 15:24
@devversion
devversion marked this pull request as ready for review July 8, 2024 15:24
@pullapprove
pullapprove Bot requested review from alan-agius4, clydin and dgp1130 July 8, 2024 15:24
@devversion

Copy link
Copy Markdown
Member Author

Note: Tooling approval not needed as the signature of the function did not change.

Comment thread packages/compiler-cli/src/ngtsc/annotations/directive/src/handler.ts Outdated
…-out

Currently when compiling code with the Angular compiler, all classes
with Angular decorators are compiled with AOT. This includes type
checking, scope collection etc.

This may not be desirable for all components, e.g. dynamic components,
or test components w/ `TestBed.configureTestingModule` (if compiled with ngtsc).

Those components can opt out of AOT on a per component-basis via `jit:
true`. This is helpful as it allows incremental migrations/refactorings
to AOT. Whether we want to keep this capability long-term is something
to be discussed separately.

For now though, we should fix that components compiled with `jit: true`
actually work as expected. Currently this **not the case** as soon as
the new initializer APIs are used— as those do no longer declare class
metadata with decorators.

This commit runs the JIT transform on JIT-opted classes.

Related: https://docs.google.com/document/d/1ox4atCJldWWDXlaYgwM-hU8BNsTpKNW7gx8OfZ0HtRY/edit?resourcekey=0-G1haTNYtD-dN0vNRkQ8_OQ&tab=t.0
This commit moves the JIT transforms into the ngtsc folder. They existed
outside of ngtsc mostly as an historic artifact— and now with compiler
relying on them even more deeply, it makes sense to move them into
`ngtsc/transform`.
@devversion devversion added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jul 10, 2024
@pkozlowski-opensource

Copy link
Copy Markdown
Member

This PR was merged into the repository by commit 7f550ea.

The changes were merged into the following branches: main

pkozlowski-opensource pushed a commit that referenced this pull request Jul 10, 2024
This commit moves the JIT transforms into the ngtsc folder. They existed
outside of ngtsc mostly as an historic artifact— and now with compiler
relying on them even more deeply, it makes sense to move them into
`ngtsc/transform`.

PR Close #56892
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Aug 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: compiler Issues related to `ngc`, Angular's template compiler detected: feature PR contains a feature commit PullApprove: disable target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants