Open kdubb1337 opened 1 year ago
We've also got a need for Decimal.js support (and some other internal/misc types). Feels like we need some sort of "bring-your-own-superjson" support where we can provide the instance or ensure our type registrations happen before this plugin uses superjson. I tried to hack this into the plugin with this commit. That built and I was able to yarn link my custom build into our app but I was getting memory access errors and an error about not being able to find the React module for some reason.
I'm not a rust guy, but steps I used to build were:
I'm migrating a Pages
router based NextJS application to the new App
router and I'm facing the same issue.
In the Pages
router application I registered custom types (Decimal.js) successfully in _app.tsc
like documenten here: https://github.com/blitz-js/superjson#decimaljs--prismadecimal
SuperJSON.registerCustom<Prisma.Decimal, string>(
{
isApplicable: (v): v is Prisma.Decimal => Prisma.Decimal.isDecimal(v),
serialize: v => v.toJSON(),
deserialize: v => new Prisma.Decimal(v),
},
'decimal.js'
)
For the App
router I did the same in layout.tsx
(?? correct ??) but then when including a component like:
<PersonTable persons={persons} data-superjson />
it gives me the Error: Trying to deserialize unknown custom value
as well...
Does the next-superjson-plugin
not support the App
router with custom types yet?
This is unfortunately blocking me from upgrading to the App
router.
Any updates on this, @orionmiz? It's a huge blocker for me with upgrading to the app router.
Verify Next.js canary release
Describe the bug
Non-default object types aren't picked up and you get the following error:
I followed the suggested custom recipe format and inject it near the root of my app:
Expected behavior
The
next-superjson-plugin
should function the same assuperjson
when called directly.Reproduction link
No response
Version
^0.5.7
Config
Additional context
I was able to follow the example from Superjson on adding custom types and can use superjson directly to serialize and then parse it back to the original object, but when using
data-superjson
it doesn't work and I get the error above.