Skip to content

Conversation

clydin
Copy link
Member

@clydin clydin commented Sep 29, 2025

Previously, any TypeScript file processed by the Angular esbuild plugin had to be part of the main TypeScript compilation defined in tsconfig.json. This caused errors for valid use cases, such as importing utility scripts that don't contain Angular-specific code.

This change introduces a more flexible approach:

  • If a file is not found in the TS compilation, its contents are checked for Angular metadata (e.g., @Component, @NgModule).
  • If Angular metadata is present, an error is correctly reported with an improved, actionable diagnostic message.
  • If no Angular metadata is found, the file is passed to esbuild with a warning, allowing it to be included in the bundle without being type-checked.

This improves the developer experience by reducing build failures for non-critical files while maintaining strict compilation for core Angular code. The diagnostic messages are now clearer and provide better guidance.

Previously, any TypeScript file processed by the Angular esbuild plugin had to be part of the main TypeScript compilation defined in `tsconfig.json`. This caused errors for valid use cases, such as importing utility scripts that don't contain Angular-specific code.

This change introduces a more flexible approach:
- If a file is not found in the TS compilation, its contents are checked for Angular metadata (e.g., `@Component`, `@NgModule`).
- If Angular metadata is present, an error is correctly reported with an improved, actionable diagnostic message.
- If no Angular metadata is found, the file is passed to esbuild with a warning, allowing it to be included in the bundle without being type-checked.

This improves the developer experience by reducing build failures for non-critical files while maintaining strict compilation for core Angular code. The diagnostic messages are now clearer and provide better guidance.
@clydin clydin added the target: major This PR is targeted for the next major release label Sep 29, 2025
@clydin clydin marked this pull request as ready for review September 29, 2025 17:23
@clydin clydin requested a review from alan-agius4 September 29, 2025 17:23
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Sep 29, 2025
@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 Sep 30, 2025
@clydin clydin merged commit ac10f32 into angular:main Sep 30, 2025
36 checks passed
@clydin clydin deleted the application/optional-ts-files branch September 30, 2025 16:16
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: @angular/build target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants