Skip to content

fix(@angular/build): anchor debug ID comment matching and make injection idempotent#33572

Open
clydin wants to merge 1 commit into
angular:mainfrom
clydin:fix/debug-id-regex-correctness
Open

fix(@angular/build): anchor debug ID comment matching and make injection idempotent#33572
clydin wants to merge 1 commit into
angular:mainfrom
clydin:fix/debug-id-regex-correctness

Conversation

@clydin

@clydin clydin commented Jul 15, 2026

Copy link
Copy Markdown
Member

Anchor the DEBUG_ID_COMMENT regex to the end of the file to prevent it from matching and replacing comments nested inside string literals or template literals. Introduce the stripDebugIdFromSourceMap utility to clean source map text before hashing, making injectDebugIds idempotent in-memory.

@clydin clydin added the target: minor This PR is targeted for the next minor release label Jul 15, 2026

@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 introduces changes to ensure deterministic and idempotent hashing of source maps by stripping any existing debugId field before generating a new debug ID hash. It also refactors the debug ID comment matching and replacement logic to be more robust. The feedback highlights a potential bug in the regex-based stripDebugIdFromSourceMap function, which can result in invalid JSON if debugId is the first property in the source map, and suggests a more robust regex along with an additional test case to cover this scenario.

Comment thread packages/angular/build/src/utils/debug-id.ts
Comment thread packages/angular/build/src/utils/debug-id_spec.ts
@clydin clydin force-pushed the fix/debug-id-regex-correctness branch from 7e19d38 to d563680 Compare July 15, 2026 14:24
@clydin

clydin commented Jul 15, 2026

Copy link
Copy Markdown
Member Author

/gemini review

@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 makes debug ID generation for source maps deterministic and idempotent by stripping any existing debugId from the source map before hashing. It also updates the JS injection logic to safely replace existing debug ID comments at the end of files. The review feedback suggests caching map.text in a local variable to avoid decoding the source map buffer multiple times, which will improve build performance.

Comment thread packages/angular/build/src/builders/application/inject-debug-ids.ts Outdated
…ion idempotent

Anchor the DEBUG_ID_COMMENT regex to the end of the file to prevent it from matching and replacing comments nested inside string literals or template literals. Introduce the stripDebugIdFromSourceMap utility to clean source map text before hashing, making injectDebugIds idempotent in-memory.
@clydin clydin force-pushed the fix/debug-id-regex-correctness branch from d563680 to 846fa94 Compare July 15, 2026 14:33
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Jul 15, 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: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant