Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dev-server-core): WebSocketsPlugin: polyfill structuredClone to support older browsers (e.g. Safari < 15.4) #2832

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

larabr
Copy link

@larabr larabr commented Oct 23, 2024

What I did

  1. Polyfill structuredClone to support browsers that do not implement in natively, e.g. Safari below v15.4 (https://developer.mozilla.org/en-US/docs/Web/API/Window/structuredClone#browser_compatibility)

Copy link

changeset-bot bot commented Oct 23, 2024

🦋 Changeset detected

Latest commit: a876456

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@web/dev-server-core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@larabr larabr marked this pull request as draft October 23, 2024 14:10
@larabr larabr marked this pull request as ready for review October 23, 2024 15:05
@@ -40,7 +48,7 @@ export function webSocketsPlugin(): Plugin {
}

export function stable (obj, replacer, spacer) {
var target = structuredClone(obj)
var target = ('structuredClone' in globalThis) ? structuredClone(obj) : structuredClonePolyfill(obj)
Copy link
Member

@bashmish bashmish Oct 24, 2024

Choose a reason for hiding this comment

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

normally we recommend to setup polyfills via the polyfills loader plugin for your app/feature
https://github.com/modernweb-dev/web/tree/master/packages/dev-server-polyfill
in this case the API in question is used in the core of WDS itself, so a little bit different situation, but in the long run I think it might still be better to manage polyfills separately using the generic approach, I recommend you to consider that

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.

2 participants