-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Labels
bugSomething isn't workingSomething isn't working
Milestone
Description
Verify Next.js canary release
- I verified that the issue exists in the latest 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/[email protected]/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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working