Skip to content

fix(@angular/build): return direct file contents for non-Angular TypeScript files - #33808

Open
alan-agius4 wants to merge 1 commit into
angular:mainfrom
alan-agius4:fix-build-compiler-plugin-non-angular-ts
Open

fix(@angular/build): return direct file contents for non-Angular TypeScript files#33808
alan-agius4 wants to merge 1 commit into
angular:mainfrom
alan-agius4:fix-build-compiler-plugin-non-angular-ts

Conversation

@alan-agius4

@alan-agius4 alan-agius4 commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

When a TypeScript file is requested that was not emitted by the TypeScript program compiler (contents === undefined), the compiler plugin checks whether the file requires Angular compiler transformations via requiresAngularCompiler(directContents).

If the file does not require the Angular compiler, the load hook returns an object with loader: 'ts' and a missing file warning so esbuild can compile it directly. However, it previously returned contents (which was still undefined) instead of directContents (which was read directly from disk via readFile). This caused esbuild to receive an empty/undefined content object rather than the actual file source code.

This change ensures contents: directContents is returned so esbuild can properly transpile the file.

@alan-agius4
alan-agius4 marked this pull request as ready for review August 7, 2026 15:27
…Script files

When a TypeScript file is requested that was not emitted by the TypeScript program compiler (`contents === undefined`), the compiler plugin checks whether the file requires Angular compiler transformations via `requiresAngularCompiler(directContents)`.

If the file does not require the Angular compiler, the load hook returns an object with `loader: 'ts'` and a missing file warning so esbuild can compile it directly. However, it previously returned `contents` (which was still `undefined`) instead of `directContents` (which was read directly from disk via `readFile`). This caused esbuild to receive an empty/undefined content object rather than the actual file source code.

This change ensures `contents: directContents` is returned so esbuild can properly transpile the file.
@alan-agius4
alan-agius4 force-pushed the fix-build-compiler-plugin-non-angular-ts branch from 800d25e to 40322c5 Compare August 7, 2026 15:27

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates the Angular compiler plugin for esbuild to return directContents instead of contents when a file does not require the Angular compiler. This ensures the correct file contents are passed through the build pipeline. There are no review comments, and I have no additional feedback to provide.

@alan-agius4
alan-agius4 requested a review from clydin August 7, 2026 15:29
@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer area: @angular/build target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant