Skip to content

fix(@angular/build): use component file path in inline stylesheet diagnostic locations - #34427

Open
alan-agius4 wants to merge 3 commits into
angular:mainfrom
alan-agius4:fix/inline-stylesheet-error-location
Open

alan-agius4 wants to merge 3 commits into
angular:mainfrom
alan-agius4:fix/inline-stylesheet-error-location

Conversation

@alan-agius4

Copy link
Copy Markdown
Collaborator

Summary

  • When bundling inline component stylesheets via ComponentStylesheetBundler.bundleInline, esbuild attaches the virtual URI angular:styles/component:<lang>;<hash>;<filename> as location.file on syntax and resolution diagnostics.
  • Rewrite any location.file starting with angular:styles/component: on errors, warnings, and their notes to filename, and record the component file in bundlerContext.watchFiles when errors occur.

Testing

  • Added unit tests in component-stylesheets_spec.ts verifying that inline stylesheet errors and warnings report the component filename instead of the internal angular:styles/component: virtual URI.

…gnostic locations

Rewrite internal angular:styles/component:<lang>;<hash>;<filename> virtual URIs in inline component stylesheet error, warning, and note locations to the component's file path, and ensure the component file path is added to watchFiles on error.
@alan-agius4 alan-agius4 added target: patch This PR is targeted for the next patch release action: review The PR is still awaiting reviews from at least one requested reviewer labels Oct 20, 2026
@alan-agius4
alan-agius4 marked this pull request as ready for review October 20, 2026 09:33
@alan-agius4
alan-agius4 requested a review from clydin October 20, 2026 09:33

@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 ComponentStylesheetBundler to map virtual URIs (starting with 'angular:styles/component:') in esbuild error and warning locations back to the actual component filename, and adds corresponding unit tests. A review comment correctly identifies a potential runtime TypeError if 'file' is undefined when calling 'startsWith()', as well as potential iteration errors if 'notes' is undefined. It is recommended to apply the suggested optional chaining and nullish coalescing fixes.

Comment thread packages/angular/build/src/tools/esbuild/angular/component-stylesheets.ts Outdated
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