blitz-js / babel-plugin-superjson-next

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

Optimize to only add HOC on pages that use getServerSideProps #41

Closed flybayer closed 3 years ago

flybayer commented 3 years ago

In https://github.com/blitz-js/babel-plugin-superjson-next/pull/34 we removed our detection logic because it was failing.

But we should try to find a way to optimize this again.

After that, I got a suspicion that the issue we had could be related to the order of the babel plugin. If this runs before next.js plugins, then it's good. But if next.js runs first, then this fails.

Skn0tt commented 3 years ago

Optimizing would save ~6kb on pages where SuperJSON isn‘t needed. Since Next.js will put that into the main bundle relatively fast anyway, I‘m not really sure wether optimization is worth it. Relying on Babel order is finicky, anyway ...