Repository navigation
fix(@angular/build): preserve incremental .d.ts signatures and emit state in watch mode - #34343
Conversation
There was a problem hiding this comment.
Code Review
This pull request improves incremental compilation and rebuild behavior in AOT compilation, particularly when isolatedModules is enabled or when .d.ts signatures are modified. It introduces a helper to ensure pre-declaration transformers are executed before declaration transforms during .d.ts-only emits, and tracks transitive importers to restore their .d.ts signatures. Additionally, two new watch-mode integration tests are added. Feedback suggests using the explicit ts.EmitOnly.Js enum instead of the magic number 0 cast to boolean to improve code readability.
3fddde5 to
e89b3d4
Compare
…tate in watch mode - Drain newly created .ngtypecheck.ts shims after collectDiagnostics() using emitNextAffectedFile with isolatedModules and assumeChangesOnlyAffectDirectDependencies enabled so TypeScript does not reset .d.ts shape signatures or queue component files into affectedFilesPendingEmit for the next rebuild. - Ensure before transformers run prior to afterDeclarations during .d.ts-only emits so Angular's declarationTransformFactory always has populated dtsTransforms. - Only record source files as emitted when JS output is produced (not on .d.ts-only checks), and pass ts.EmitOnly.Js in the fallback loop when .d.ts was already emitted. - Track transitive importers whose BuilderProgram signatures are reset to sourceFile.version by handleDtsMayChangeOf so populatePreviousDtsSignatures restores their .d.ts signatures on subsequent edits.
e89b3d4 to
76d8516
Compare
|
This PR was merged into the repository. The changes were merged into the following branches:
|
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
.ngtypecheck.tsshims aftercollectDiagnostics()usingemitNextAffectedFilewithisolatedModulesandassumeChangesOnlyAffectDirectDependenciesenabled so TypeScript does not walkreferencedMapfrom.ngtypecheck.tsshims to component.tsfiles and their transitive importers, preserving their.d.tsshape signatures and keepingaffectedFilesPendingEmitclean for the next watch rebuild.beforetransformers (ivyTransformFactory) have executed on the originalSourceFileprior toafterDeclarations(declarationTransformFactory) when TypeScript performs a.d.ts-only emit (emitOnly = Dts) for transitive importers.SourceFileas having completed JS emit inwriteFileCallbackwhen only a.d.tsor.mapfile was emitted during a.d.ts-only check, and passts.EmitOnly.Jsin the fallback loop when.d.tswas already emitted.BuilderProgramshape signatures are reset tosourceFile.versionbyhandleDtsMayChangeOfduringfindAffectedFiles()sopopulatePreviousDtsSignatures()restores their.d.tssignatures if they are modified on a subsequent rebuild.