fix(compiler-cli): ensure the compiler tracks ts.Programs correctly#41291
fix(compiler-cli): ensure the compiler tracks ts.Programs correctly#41291alxhub wants to merge 1 commit intoangular:masterfrom
ts.Programs correctly#41291Conversation
19bc8e2 to
74d4ca6
Compare
There was a problem hiding this comment.
If the input program (program#1) hasn't changed, but there are some operations that cause additional private TCB code to be generated after step 2, is the new program generated based on (1) or (2)?
Could you please clarify this in the example above?
There was a problem hiding this comment.
This example is describing "under a normal compilation", meaning the normal functioning of ngc with no usage of TemplateTypeChecker APIs directly.
There was a problem hiding this comment.
I added a section to clarify how such a client might consume TsCreateProgramDriver and manage programs that way.
74d4ca6 to
2f62e5d
Compare
2f62e5d to
51ac5d9
Compare
josephperrott
left a comment
There was a problem hiding this comment.
LGTM
Reviewed-for: dev-infra
51ac5d9 to
7246174
Compare
`NgCompiler` previously had a notion of the "next" `ts.Program`, which served two purposes: * it allowed a client using the `ts.createProgram` API to query for the latest program produced by the previous `NgCompiler`, as a starting point for building the _next_ program that incorporated any new user changes. * it allowed the old `NgCompiler` to be queried for the `ts.Program` on which all prior state is based, which is needed to compute the delta from the new program to ultimately determine how much of the prior state can be reused. This system contained a flaw: it relied on the `NgCompiler` knowing when the `ts.Program` would be changed. This works fine for changes that originate in `NgCompiler` APIs, but a client of the `TemplateTypeChecker` may use that API in ways that create new `ts.Program`s without the `NgCompiler`'s knowledge. This caused the `NgCompiler`'s concept of the "next" program to get out of sync, causing incorrectness in future incremental analysis. This refactoring cleans up the compiler's `ts.Program` management in several ways: * `TypeCheckingProgramStrategy`, the API which controls `ts.Program` updating, is renamed to the `ProgramDriver` and extracted to a separate ngtsc package. * It loses its responsibility of determining component shim filenames. That functionality now lives exclusively in the template type-checking package. * The "next" `ts.Program` concept is renamed to the "current" program, as the "next" name was misleading in several ways. * `NgCompiler` now wraps the `ProgramDriver` used in the `TemplateTypeChecker` to know when a new `ts.Program` is created, regardless of which API drove the creation, which actually fixes the bug.
7246174 to
9019cc2
Compare
…rFactory With the work done in angular#41291, the compiler always tracks the last known program, so there's no need to track the program in the compiler factory anymore.
|
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. |
NgCompilerpreviously had a notion of the "next"ts.Program, whichserved two purposes:
it allowed a client using the
ts.createProgramAPI to query for thelatest program produced by the previous
NgCompiler, as a startingpoint for building the next program that incorporated any new user
changes.
it allowed the old
NgCompilerto be queried for thets.Programonwhich all prior state is based, which is needed to compute the delta
from the new program to ultimately determine how much of the prior
state can be reused.
This system contained a flaw: it relied on the
NgCompilerknowing whenthe
ts.Programwould be changed. This works fine for changes thatoriginate in
NgCompilerAPIs, but a client of theTemplateTypeCheckermay use that API in ways that create new
ts.Programs without theNgCompiler's knowledge. This caused theNgCompiler's concept of the"next" program to get out of sync, causing incorrectness in future
incremental analysis.
This refactoring cleans up the compiler's
ts.Programmanagement inseveral ways:
TypeCheckingProgramStrategy, the API which controlsts.Programupdating, is renamed to the
ProgramDriverand extracted to a separatengtsc package.
It loses its responsibility of determining component shim filenames. That
functionality now lives exclusively in the template type-checking package.
The "next"
ts.Programconcept is renamed to the "current" program, asthe "next" name was misleading in several ways.
NgCompilernow wraps theProgramDriverused in theTemplateTypeCheckerto know when a newts.Programis created,regardless of which API drove the creation, which actually fixes the bug.