Skip to content

Conversation

clydin
Copy link
Member

@clydin clydin commented Dec 5, 2024

TypeScript 5.6 and higher added functionality that will search for a package.json file for source files that are part of the program (e.g., .d.ts) and within a node modules directory. This can be an expensive tasks especially considering the large amount of .d.ts files within packages. TypeScript supports using a cache of known package.json files to improve the performance of this task. The Angular CLI will now provide and reuse this cache across rebuilds during watch mode. This includes the use of ng serve.

The performance difference is most apparent for the Angular template diagnostic step of the build. Internally the Angular compiler creates a new template typechecking program which causes the package.json search process to occur. By leveraging the cache, this process becomes a series of cache hits. In the event that files are modified within the node modules directory, the cache is invalidated and the following rebuild may be longer as a result.

(cherry picked from commit 75998eb)

@clydin clydin added the target: patch This PR is targeted for the next patch release label Dec 5, 2024
@clydin clydin requested a review from alan-agius4 December 5, 2024 12:32
@angular-robot angular-robot bot added area: performance Issues related to performance area: @angular/build labels Dec 5, 2024
@alan-agius4 alan-agius4 added the action: merge The PR is ready for merge by the caretaker label Dec 5, 2024
TypeScript 5.6 and higher added functionality that will search for a
`package.json` file for source files that are part of the program (e.g., `.d.ts`)
and within a node modules directory. This can be an expensive tasks especially
considering the large amount of `.d.ts` files within packages. TypeScript supports
using a cache of known `package.json` files to improve the performance of this task.
The Angular CLI will now provide and reuse this cache across rebuilds during watch
mode. This includes the use of `ng serve`.

The performance difference is most apparent for the Angular template diagnostic
step of the build. Internally the Angular compiler creates a new template typechecking
program which causes the `package.json` search process to occur. By leveraging the
cache, this process becomes a series of cache hits. In the event that files are modified
within the node modules directory, the cache is invalidated and the following rebuild
may be longer as a result.

(cherry picked from commit 75998eb)
@alan-agius4 alan-agius4 force-pushed the ts-package-cache-19.0.x branch from a6d739c to c706d20 Compare December 5, 2024 15:13
@alan-agius4 alan-agius4 merged commit 14451e2 into angular:19.0.x Dec 5, 2024
30 checks passed
@clydin clydin deleted the ts-package-cache-19.0.x branch December 5, 2024 16:11
@angular-automatic-lock-bot
Copy link

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 Jan 5, 2025
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: @angular/build area: performance Issues related to performance target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants