Replaces require('lodash.clonedeep'). That was a bare CommonJS require in a
file re-exported through the public barrel, which tsc leaves untouched in the
ESM output — so any native-ESM consumer hit "require is not defined in ES module
scope" the moment the package was imported.
structuredClone is not a substitute here: the serialization layer clones
typedjson member metadata, which holds constructor references and
serializer/deserializer hooks, and structuredClone throws on functions.
Matching lodash, functions are therefore carried over by reference rather than
cloned, and prototypes are preserved so class instances stay their own type.
Deep clone a value.
Replaces
require('lodash.clonedeep'). That was a bare CommonJS require in a file re-exported through the public barrel, which tsc leaves untouched in the ESM output — so any native-ESM consumer hit "require is not defined in ES module scope" the moment the package was imported.structuredCloneis not a substitute here: the serialization layer clones typedjson member metadata, which holds constructor references and serializer/deserializer hooks, and structuredClone throws on functions. Matching lodash, functions are therefore carried over by reference rather than cloned, and prototypes are preserved so class instances stay their own type.