Problem
When a reviver is passed and the loaded module has no default export, wisp falls back to the module namespace object and passes it through structuredClone. A module namespace can't be structured-cloned, so the call throws. That error gets caught and reported as wisp's generic "Unsupported type" error, which hides the real cause and fails a load that should either work or give a clear error.
Found while porting the suite to vitest-runner (#37). The new tests pin the current behaviour.
Fix
Decide the contract for a module without a default export when a reviver is given:
- either apply the reviver to a plain-object copy of the namespace's own enumerable properties (
{ ...ns }) rather than structuredClone(ns),
- or throw a clear error saying a reviver needs a JSON value or a default export.
Then update the pinned test to the intended behaviour, for both wisp and wispSync where applicable.
Problem
When a
reviveris passed and the loaded module has no default export, wisp falls back to the module namespace object and passes it throughstructuredClone. A module namespace can't be structured-cloned, so the call throws. That error gets caught and reported as wisp's generic "Unsupported type" error, which hides the real cause and fails a load that should either work or give a clear error.Found while porting the suite to vitest-runner (#37). The new tests pin the current behaviour.
Fix
Decide the contract for a module without a default export when a reviver is given:
{ ...ns }) rather thanstructuredClone(ns),Then update the pinned test to the intended behaviour, for both
wispandwispSyncwhere applicable.