Verify Next.js canary release
Describe the bug
Non-default object types aren't picked up and you get the following error:
- error node_modules/.pnpm/superjson@1.12.2/node_modules/superjson/dist/transformer.js (184:0) @ Object.eval [as untransform]
- error Error: Trying to deserialize unknown custom value
at Array.forEach ()
null
I followed the suggested custom recipe format and inject it near the root of my app:
import SuperJSON from 'superjson'
export function registerCustomTypes() {
// Register Decimal as a custom type
// Ref: https://github.com/blitz-js/superjson/pull/159/files
SuperJSON.registerCustom<Decimal, string>(
{
isApplicable: (v): v is Decimal => Decimal.isDecimal(v),
serialize: (v) => v.toJSON(),
deserialize: (v) => new Decimal(v),
},
'Decimal',
)
}
Expected behavior
The next-superjson-plugin should function the same as superjson when called directly.
Reproduction link
No response
Version
^0.5.7
Config
export default {
reactStrictMode: true,
swcMinify: true,
images: {
domains: [],
},
experimental: {
appDir: true,
serverComponentsExternalPackages: ['@prisma/client'],
swcPlugins: [['next-superjson-plugin', {}]],
},
}
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.
Verify Next.js canary release
Describe the bug
Non-default object types aren't picked up and you get the following error:
at Array.forEach ()
null
I followed the suggested custom recipe format and inject it near the root of my app:
Expected behavior
The
next-superjson-pluginshould function the same assuperjsonwhen 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-superjsonit doesn't work and I get the error above.