APIDevTools / json-schema-ref-parser

Parse, Resolve, and Dereference JSON Schema $ref pointers in Node and browsers
https://apitools.dev/json-schema-ref-parser
MIT License
942 stars 226 forks source link

clonedeep vs structuredClone #328

Closed jimmywarting closed 5 months ago

jimmywarting commented 10 months ago

Just want to point out that there is a structuredClone natively that dose not require any dependencies...

https://github.com/APIDevTools/json-schema-ref-parser/blob/26d824b4b230f4ce2471f73401a4b6f7c7c67ac2/package.json#L98

maybe consider doing a conditional top level import or something like that?

const clone = globalThis.structuredClone || await import('lodash.clonedeep')

or let the user know that it requires support for structuredClone and it needs to be polyfilled

jonluca commented 5 months ago

We still support node 16, and structuredClone was introduced in 17. Once we drop support for 16 we'll get rid of the lodash dependency

jonluca commented 5 months ago

Turns out we didnt need cloneDeep or any dependency at all

https://github.com/APIDevTools/json-schema-ref-parser/commit/52ab2f8d2c05eba0dff99d68f34f793f3d340d50