Fix ESM XHR instrumentation tree shaking - #2768
Merged
Hector Hernandez (hectorhdzg) merged 1 commit intoSep 8, 2026
Merged
Conversation
Remove the no-side-effects annotation from isXhrSupported so Rollup preserves capability checks that install XHR instrumentation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Hector Hernandez (hectorhdzg)
requested a review
from a team
as a code owner
September 8, 2026 20:48
Copilot started reviewing on behalf of
Hector Hernandez (hectorhdzg)
September 8, 2026 20:48
View session
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped, aligns with the reported Rollup/Vite ESM regression, and does not introduce new logic beyond preventing an unsafe optimization.
Pull request overview
Fixes an ESM tree-shaking regression where XHR (Ajax) instrumentation could be silently skipped when bundlers (Rollup/Vite) removed capability-check branches based on a “no side effects” annotation.
Changes:
- Removed the
/*#__NO_SIDE_EFFECTS__*/annotation fromisXhrSupported()to prevent Rollup from incorrectly optimizing away XHR capability checks. - Added an in-code rationale comment to discourage reintroducing the annotation and to document the bundler impact.
File summaries
| File | Description |
|---|---|
| shared/AppInsightsCore/src/utils/EnvUtils.ts | Removes side-effect-free annotation from isXhrSupported() and documents why, ensuring XHR instrumentation install checks aren’t tree-shaken away in ESM builds. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Jackson Weber (JacksonWeber)
approved these changes
Sep 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Remove the no-side-effects annotation from isXhrSupported so Rollup preserves capability checks that install XHR instrumentation.
Fixes #2750
Fixes #2760