Skip to content

Replace @ungap/structured-clone with native structuredClone#26890

Merged
ChumpChief merged 5 commits intomicrosoft:mainfrom
ChumpChief:remove-ungap-structured-clone
Apr 14, 2026
Merged

Replace @ungap/structured-clone with native structuredClone#26890
ChumpChief merged 5 commits intomicrosoft:mainfrom
ChumpChief:remove-ungap-structured-clone

Conversation

@ChumpChief
Copy link
Copy Markdown
Contributor

@ChumpChief ChumpChief commented Mar 30, 2026

Summary

  • Remove @ungap/structured-clone (production dep) and @types/ungap__structured-clone (dev dep) from app-insights-logger, container-loader, and tree
  • Native structuredClone is available in all supported environments (Node 20+ and ES2022 browsers), making this polyfill unnecessary
  • In tree, the internal clone re-export from utils.ts is removed and the one test consumer is updated to use structuredClone directly. This export was not part of the public API.
  • Expose structuredClone in @fluid-example/app-insights-logger's Jest config globals, since the jsdom test environment does not provide it

Bundle size impact

Measured via @fluid-example/bundle-size-tests:

Bundle Before After Diff %
loader.js 146,539 bytes 144,162 bytes -2,377 bytes -1.6%
azureClient.js 616,481 bytes 614,102 bytes -2,379 bytes -0.4%
odspClient.js 589,174 bytes 586,795 bytes -2,379 bytes -0.4%

All other bundles unchanged.

Test plan

  • pnpm build and pnpm test pass in app-insights-logger (21 tests)
  • pnpm build and pnpm test pass in container-loader (220 tests)
  • pnpm build and pnpm test pass in tree (13,692 tests)
  • pnpm test passes in @fluid-example/app-insights-logger

🤖 Generated with Claude Code

Native structuredClone is available in all supported environments
(Node 20+ and ES2022 browsers). Remove the polyfill from
app-insights-logger, container-loader, and tree. In tree, the
internal clone re-export is removed and the one test consumer is
updated to use structuredClone directly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ChumpChief ChumpChief marked this pull request as ready for review March 30, 2026 21:36
@ChumpChief ChumpChief requested a review from a team as a code owner March 30, 2026 21:36
Copilot AI review requested due to automatic review settings March 30, 2026 21:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the @ungap/structured-clone polyfill (and its types) and switches call sites to the native global structuredClone, relying on the repo’s supported runtime environments where it is available.

Changes:

  • Removed @ungap/structured-clone and @types/ungap__structured-clone dependencies from container-loader, app-insights-logger, and tree (and updated lockfile).
  • Updated container-loader and app-insights-logger to use the global structuredClone (no import).
  • Removed the internal clone re-export from tree utils and updated the one test consumer to call structuredClone directly.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pnpm-lock.yaml Removes lock entries for @ungap/structured-clone and its types from affected importers.
packages/loader/container-loader/src/container.ts Drops the polyfill import; continues cloning via global structuredClone.
packages/loader/container-loader/package.json Removes @ungap/structured-clone and @types/ungap__structured-clone.
packages/framework/client-logger/app-insights-logger/src/fluidAppInsightsLogger.ts Drops the polyfill import; continues deep-copying config via global structuredClone.
packages/framework/client-logger/app-insights-logger/package.json Removes @ungap/structured-clone and @types/ungap__structured-clone.
packages/dds/tree/src/util/utils.ts Removes internal clone re-export of the polyfill.
packages/dds/tree/src/util/index.ts Stops re-exporting clone from util barrel.
packages/dds/tree/src/test/shared-tree-core/edit-manager/editManagerScenario.ts Updates test to use global structuredClone instead of util clone.
packages/dds/tree/package.json Removes @ungap/structured-clone and @types/ungap__structured-clone.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

@ChumpChief ChumpChief marked this pull request as draft March 30, 2026 23:11
@ChumpChief
Copy link
Copy Markdown
Contributor Author

Moving back to draft while confirming browser support requirements.

ChumpChief and others added 2 commits March 31, 2026 09:43
The jsdom environment doesn't provide structuredClone. Now that
container-loader uses native structuredClone instead of the
@ungap/structured-clone polyfill, it needs to be explicitly exposed
in the Jest config globals.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ChumpChief ChumpChief marked this pull request as ready for review April 10, 2026 16:11
@ChumpChief
Copy link
Copy Markdown
Contributor Author

Updated downstream browser support requirements, structuredClone should be fine to use as a result.

Copy link
Copy Markdown
Contributor

@alexvy86 alexvy86 left a comment

Choose a reason for hiding this comment

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

Seems good to me. I suggest also getting eyes from someone in tree.

ChumpChief and others added 2 commits April 10, 2026 11:32
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@CraigMacomber CraigMacomber left a comment

Choose a reason for hiding this comment

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

Tree changes look good to me.

@ChumpChief ChumpChief merged commit 5fd4587 into microsoft:main Apr 14, 2026
30 checks passed
@ChumpChief ChumpChief deleted the remove-ungap-structured-clone branch April 14, 2026 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants