Hey, I am currently using devalue as part of a sveltekit project and I really like the new Temporal API. Unfortunately, I can not send Temporal objects to the client with e.g. a Safari browser because I get
ReferenceError: Can't find variable: Temporal
I tried it with the following in the hooks.ts file:
import { Temporal } from '@js-temporal/polyfill';
import type { Transport } from '@sveltejs/kit';
export const transport: Transport = {
'Temporal.Duration': {
encode: (value) => value instanceof Temporal.Duration && [value.toString()],
decode: ([value]) => Temporal.Duration.from(value),
},
'Temporal.Instant': {
encode: (value) => value instanceof Temporal.Instant && [value.toString()],
decode: ([value]) => Temporal.Instant.from(value),
}
}
It would be really great to somehow opt in to loading a polyfill as a fallback (e.g. "@js-temporal/polyfill") to at least ensure that the app still works. Or is there currently any workaround possible so that I can achieve this goal? Right now, I am loading this polyfill already in several places but it seems like I can not override how the Temporal object should parsed/stringified.
Thank you very much in advance!
Hey, I am currently using devalue as part of a sveltekit project and I really like the new Temporal API. Unfortunately, I can not send Temporal objects to the client with e.g. a Safari browser because I get
I tried it with the following in the
hooks.tsfile:It would be really great to somehow opt in to loading a polyfill as a fallback (e.g. "@js-temporal/polyfill") to at least ensure that the app still works. Or is there currently any workaround possible so that I can achieve this goal? Right now, I am loading this polyfill already in several places but it seems like I can not override how the Temporal object should parsed/stringified.
Thank you very much in advance!