import { query } from '$app/server';import { Schema } from 'effect';// Schema.Class instances can't be serialized with devalue// Affects both remote functions and load functions in SvelteKit// Schema.encode doesn't helpclass SomeClass extends Schema.Class<SomeClass>('SomeClass')({ test: Schema.String}) {}// This leads to `DevalueError: Cannot stringify arbitrary non-POJOs`export const getDemoPlain = query(async () => SomeClass.make({ test: 'foo' }));// I expected this to work, but the same error occursexport const getDemoWithEncode = query(async () => Schema.encode(SomeClass)(SomeClass.make({ test: 'foo' })));import { stringify } from 'devalue';// So i tried if plain devalue works, SvelteKit uses it internally// So the problem is not with devalue, but with "devalueing" Schema.Class instancesexport const getDemoWithDevalue = query(async () => stringify(SomeClass.make({ test: 'foo' })));
import { query } from '$app/server';import { Schema } from 'effect';// Schema.Class instances can't be serialized with devalue// Affects both remote functions and load functions in SvelteKit// Schema.encode doesn't helpclass SomeClass extends Schema.Class<SomeClass>('SomeClass')({ test: Schema.String}) {}// This leads to `DevalueError: Cannot stringify arbitrary non-POJOs`export const getDemoPlain = query(async () => SomeClass.make({ test: 'foo' }));// I expected this to work, but the same error occursexport const getDemoWithEncode = query(async () => Schema.encode(SomeClass)(SomeClass.make({ test: 'foo' })));import { stringify } from 'devalue';// So i tried if plain devalue works, SvelteKit uses it internally// So the problem is not with devalue, but with "devalueing" Schema.Class instancesexport const getDemoWithDevalue = query(async () => stringify(SomeClass.make({ test: 'foo' })));
How would i approach this? There is the transport hook, but adding every class there seems like a huge pain