8000 fix(compiler): remove TypeScript from linker by alan-agius4 · Pull Request #61618 · angular/angular · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(compiler): remove TypeScript from linker #61618

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

Closed

Conversation

alan-agius4
Copy link
Contributor

This commit removes the direct dependency on TypeScript within the linker, addressing a performance overhead that was adding between 500ms to 1s to compilation times for applications.

The primary cause of this overhead was the linker's direct reliance on TypeScript's which was caused by importing from barrel files. While convenient, barrel files are detrimental to code splitting and code motion. They force the bundling of all exported modules, even if only a subset is actually used.

By removing the usage of this barrel file and restructuring the imports to be more granular, we can avoid unnecessary TypeScript imports. Furthermore, TypeScript has now been changed to an optional peer dependency as using only the linker does not require TypeScript.

@angular-robot angular-robot bot added the area: compiler Issues related to `ngc`, Angular's template compiler label May 22, 2025
@ngbot ngbot bot added this to the Backlog milestone May 22, 2025
@alan-agius4 alan-agius4 force-pushed the avoid-ts-being-loaded-in-linker branch 2 times, most recently from 7319277 to 40b5ec9 Compare May 22, 2025 16:29
This commit removes the direct dependency on TypeScript within the linker, addressing a performance overhead that was adding between 500ms to 1s to compilation times for applications.

The primary cause of this overhead was the linker's direct reliance on TypeScript's which was caused by importing from barrel files. While convenient, barrel files are detrimental to code splitting and code motion. They force the bundling of all exported modules, even if only a subset is actually used.

By removing the usage of this barrel file and restructuring the imports to be more granular, we can avoid unnecessary TypeScript imports.
 Furthermore, TypeScript has now been changed to an optional peer dependency as using only the linker does not require TypeScript.
@alan-agius4 alan-agius4 requested a review from devversion May 22, 2025 18:15
@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: minor This PR is targeted for the next minor release labels May 22, 2025
@alan-agius4 alan-agius4 marked this pull request as ready for review May 22, 2025 18:15
@alan-agius4 alan-agius4 force-pushed the avoid-ts-being-loaded-in-linker branch from 40b5ec9 to 7cf2425 Compare May 22, 2025 18:15

(async () => {
// Verify that TypeScript is not installed.
await assert.rejects(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to double-check, was the loading of typescript the main issue here, or were other imports/chunks from the barrel causing the slow-down as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the primary reason.

@alan-agius4 alan-agius4 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 May 23, 2025
@thePunderWoman
Copy link
Contributor

This PR was merged into the repository by commit e9fcbb8.

The changes were merged into the following branches: main

@alan-agius4 alan-agius4 deleted the avoid-ts-being-loaded-in-linker branch May 26, 2025 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: merge The PR is ready for merge by the caretaker area: compiler Issues related to `ngc`, Angular's template compiler 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
0