Skip to content

Commit fd33716

Browse files
authored
chore: remove structuredClone workaround (#5367)
we only support environments where it exists, now
1 parent 107a414 commit fd33716

File tree

1 file changed

+2
-9
lines changed
  • packages/@lwc/template-compiler/src/codegen

1 file changed

+2
-9
lines changed

packages/@lwc/template-compiler/src/codegen/codegen.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,6 @@ import type {
6767
import type { APIVersion } from '@lwc/shared';
6868
import type { Node } from 'estree';
6969

70-
// structuredClone is only available in Node 17+
71-
// https://developer.mozilla.org/en-US/docs/Web/API/structuredClone#browser_compatibility
72-
const doStructuredClone =
73-
typeof structuredClone === 'function'
74-
? structuredClone
75-
: (obj: any) => JSON.parse(JSON.stringify(obj));
76-
7770
type RenderPrimitive =
7871
| 'iterator'
7972
| 'flatten'
@@ -649,7 +642,7 @@ export default class CodeGen {
649642
if (this.state.config.experimentalComplexExpressions) {
650643
// Cloning here is necessary because `this.replace()` is destructive, and we might use the
651644
// node later during static content optimization
652-
expression = doStructuredClone(expression);
645+
expression = structuredClone(expression);
653646
return bindComplexExpression(expression as ComplexExpression, this);
654647
}
655648

@@ -659,7 +652,7 @@ export default class CodeGen {
659652

660653
// Cloning here is necessary because `this.replace()` is destructive, and we might use the
661654
// node later during static content optimization
662-
expression = doStructuredClone(expression);
655+
expression = structuredClone(expression);
663656
// TODO [#3370]: when the template expression flag is removed, the
664657
// ComplexExpression type should be redefined as an ESTree Node. Doing
665658
// so when the flag is still in place results in a cascade of required

0 commit comments

Comments
 (0)