Skip to content

Commit 59116a5

Browse files
committed
chore: remove structuredClone workaround
we only support environments where it exists, now
1 parent de515d7 commit 59116a5

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
@@ -66,13 +66,6 @@ import type {
6666
import type { APIVersion } from '@lwc/shared';
6767
import type { Node } from 'estree';
6868

69-
// structuredClone is only available in Node 17+
70-
// https://developer.mozilla.org/en-US/docs/Web/API/structuredClone#browser_compatibility
71-
const doStructuredClone =
72-
typeof structuredClone === 'function'
73-
? structuredClone
74-
: (obj: any) => JSON.parse(JSON.stringify(obj));
75-
7669
type RenderPrimitive =
7770
| 'iterator'
7871
| 'flatten'
@@ -629,7 +622,7 @@ export default class CodeGen {
629622
if (this.state.config.experimentalComplexExpressions) {
630623
// Cloning here is necessary because `this.replace()` is destructive, and we might use the
631624
// node later during static content optimization
632-
expression = doStructuredClone(expression);
625+
expression = structuredClone(expression);
633626
return bindComplexExpression(expression as ComplexExpression, this);
634627
}
635628

@@ -639,7 +632,7 @@ export default class CodeGen {
639632

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

0 commit comments

Comments
 (0)