fix(@angular/build): anchor debug ID comment matching and make injection idempotent#33572
fix(@angular/build): anchor debug ID comment matching and make injection idempotent#33572clydin wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
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.
7e19d38 to
d563680
Compare
|
/gemini review |
There was a problem hiding this comment.
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.
…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.
d563680 to
846fa94
Compare
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.