This page would work fine without superjson or the babel transform. But after adding the babel transform, yarn build results in the following error:
Error occurred prerendering page "/no-meta". Read more: https://err.sh/next.js/prerender-error
Error: Error serializing `.meta` returned from `getStaticProps` in "/no-meta".
Reason: `undefined` cannot be serialized as JSON. Please use `null` or omit this value all together.
Looks like the issue is coming from superjson.serialize(), which returns meta: undefined when none of the properties needs custom serialization. However, NextJS has its own validation that throws if a prop is undefined.
Hi! First off, thanks for this babel transform, I've been using it in an existing NextJS project and it is 🔥
I noticed a bug while integrating this babel transform.
After setting up the plugin in
.babelrc
, here's an example page/pages/no-meta.tsx
:This page would work fine without
superjson
or the babel transform. But after adding the babel transform,yarn build
results in the following error:Looks like the issue is coming from
superjson.serialize()
, which returnsmeta: undefined
when none of the properties needs custom serialization. However, NextJS has its own validation that throws if a prop isundefined
.