Skip to content

Fix ESM XHR instrumentation tree shaking - #2768

Merged
Hector Hernandez (hectorhdzg) merged 1 commit into
microsoft:mainfrom
hectorhdzg:hectorhdzg-fix-esm-xhr-instrumentation
Sep 8, 2026
Merged

Fix ESM XHR instrumentation tree shaking#2768
Hector Hernandez (hectorhdzg) merged 1 commit into
microsoft:mainfrom
hectorhdzg:hectorhdzg-fix-esm-xhr-instrumentation

Conversation

@hectorhdzg

@hectorhdzg Hector Hernandez (hectorhdzg) commented Sep 8, 2026

Copy link
Copy Markdown
Member

Remove the no-side-effects annotation from isXhrSupported so Rollup preserves capability checks that install XHR instrumentation.

Fixes #2750
Fixes #2760

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>
Copilot AI lite review requested due to automatic review settings September 8, 2026 20:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 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 from isXhrSupported() 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.

@hectorhdzg
Hector Hernandez (hectorhdzg) merged commit 1fa8190 into microsoft:main Sep 8, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants