blitz-js / next-superjson-plugin

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

Error serializing with getStaticPaths #2

Closed nabi-chan closed 2 years ago

nabi-chan commented 2 years ago

Hi @orionmiz and Thanks for make king-wang-zzang (very wonderful) package :) However, When I getStaticPaths with NextJS 12.2.4, It's throws SerializableError It came from looks like not serializing

Is that expected behavior? And Can you know how to fix it? Thank you :)

nabi-chan commented 2 years ago

You can see my code at this link : https://github.com/KimPinot/new-blog/commit/41c164d2b888bd65445d4a6779cded686cc621cd

orionmiz commented 2 years ago

Found in next.config.js:

swcPlugins: ["next-superjson-plugin"],

Correct usage of the plugin:

swcPlugins: [["next-superjson-plugin", { excluded: [] }]],

To apply the SWC plugin, Next.js requires a tuple as an array containing both the name and the options of the plugin. https://nextjs.org/docs/advanced-features/compiler#swc-plugins-experimental

I checked good-working of your project with the replaced configuration above,

Try it!

nabi-chan commented 2 years ago

It works! thank you :)

nabi-chan commented 2 years ago

Oh, Did you checked this commit? https://github.com/KimPinot/new-blog/commit/95634fc7f22c6d53dc64899dcae23cf8ab66577a

I forgotten mention that, This commits changes Date type to number at /modules/post/article.ts When I roll-backed this commit Error shown. 🥲

Do you have a clue about this?

nabi-chan commented 2 years ago

You can reproduce this issue on here KimPinot/new-blog/nextjs-superjson

orionmiz commented 2 years ago

Sorry, I can't guess the error you are talking about.

Please make a new issue with more detailed explanations.