blitz-js / next-superjson-plugin

SuperJSON Plugin for Next.js Pages and Components
202 stars 12 forks source link

Error serializing with imported getServerSideProps #1

Closed cellulosa closed 2 years ago

cellulosa commented 2 years ago

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

orionmiz commented 2 years ago

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.

cellulosa commented 2 years ago

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! 🙌

jbwc commented 1 year ago

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