Skip to content

Commit 9a43436

Browse files
authored
refactor: remove structuredClonePolyfill (#1463)
Signed-off-by: Jan Kowalleck <[email protected]>
1 parent 50b3ab7 commit 9a43436

File tree

2 files changed

+1
-9
lines changed

2 files changed

+1
-9
lines changed

src/_helpers.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ export function isNonNullable<T>(value: T): value is NonNullable<T> {
2828
return value !== null && value !== undefined
2929
}
3030

31-
export const structuredClonePolyfill: <T>(value: T) => T = typeof structuredClone === 'function'
32-
? structuredClone
33-
: function <T>(value: T): T {
34-
/* eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- ack */
35-
return JSON.parse(JSON.stringify(value)) as T
36-
}
37-
3831
export interface ValidPackageJSON {
3932
name: string
4033
version: string

src/extractor.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import {
2727
isNonNullable,
2828
normalizePackageManifest,
2929
type PackageDescription,
30-
structuredClonePolyfill
3130
} from './_helpers'
3231

3332
type WebpackLogger = Compilation['logger']
@@ -95,7 +94,7 @@ export class Extractor {
9594
try {
9695
// work with a deep copy, because `normalizePackageManifest()` might modify the data
9796
/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- ach */
98-
const _packageJson = structuredClonePolyfill(pkg.packageJson)
97+
const _packageJson = structuredClone(pkg.packageJson)
9998
normalizePackageManifest(_packageJson)
10099
pkg.packageJson = _packageJson /* eslint-disable-line no-param-reassign -- intended */
101100
} catch (e) {

0 commit comments

Comments
 (0)