blitz-js / next-superjson-plugin

SuperJSON Plugin for Next.js Pages and Components

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error serializing with imported getServerSideProps

cellulosa opened this issue · comments

hi @orionmiz and thank you for the plugin, it works perfectly when getServerSideProps sits on the same page file.

However, I am importing a common getServerSideProps from ../utils/getServerSideProps.tsx and it that case the seralisation does not happen:

error - SerializableError: Error serializing `.fallback["/api/state"].createdAt` returned from `getServerSideProps` in "/".

Is that the intended behaviour? Is there a way to add a path to be processed?

Thank you

Thanks for reporting!

First, I designed optimization preventing nested SuperJSON wrapping
like this case assuming that gSSP & gSP functions are in a page file

For this reason, I recommend you to place those functions in the page file.

But I'm planning to develop an option disabling optimization
for users who wants to seperate gSSP & gSP functions into other files.

Cool in that case I moved getServerSideProps into a page file and call it from there from other pages. Thanks ever so much for the plugin and for the quick reply too! 🙌

Would also prefer to be able to import composable functions from other files