blitz-js / babel-plugin-superjson-next

Automatically transform your Next.js Pages to use SuperJSON
MIT License
125 stars 15 forks source link

0.2.2: Cannot set property '_superjson' of null #48

Closed typeofweb closed 3 years ago

typeofweb commented 3 years ago

Version 0.2.2 introduced a bug which breaks static build in Next.js. After downgrading to 0.2.1 everything is in order.   Log:

01:10:12.358 | Unhandled error during request: TypeError: Cannot set property '_superjson' of null
01:10:12.358 | at /vercel/workpath0/node_modules/babel-plugin-superjson-next/dist/tools.js:84:46
01:10:12.358 | at step (/vercel/workpath0/node_modules/babel-plugin-superjson-next/dist/tools.js:44:23)
01:10:12.358 | at Object.next (/vercel/workpath0/node_modules/babel-plugin-superjson-next/dist/tools.js:25:53)
01:10:12.359 | at fulfilled (/vercel/workpath0/node_modules/babel-plugin-superjson-next/dist/tools.js:16:58)

.babelrc:

{
  "presets": ["next/babel"],
  "plugins": ["superjson-next"]
}

Relevant dependencies:

"babel-plugin-superjson-next": "0.2.1",
"superjson": "1.7.2",
"next": "10.0.7",
Skn0tt commented 3 years ago

Hi @mmiszy! Thanks for submitting this bug. (@allcontributors add @mmiszy for bug)

It's most likely caused by you returning props: undefined in getServerSideProps / getStaticProps, and will also be a build error on Next.js side. Pre v0.2.2, this error was swallowed by babel-plugin-superjson-next.

51 changes this so you're shown the "real" Next.js error.

allcontributors[bot] commented 3 years ago

@Skn0tt

I've put up a pull request to add @mmiszy! :tada: