Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared SSR/SSG hooks are not transformed #121

Open
alii opened this issue Mar 28, 2022 · 4 comments · May be fixed by #122
Open

Shared SSR/SSG hooks are not transformed #121

alii opened this issue Mar 28, 2022 · 4 comments · May be fixed by #122

Comments

@alii
Copy link

alii commented Mar 28, 2022

When writing getStaticProps outside of a page file, the superjson code is never injected. For example:

// props.ts
export const getStaticProps: GetStaticProps<Props> = async ctx => {
	// ...
}

// pages/page.tsx
export {getStaticProps} from '../props';

export default function Page() {
	// ...
}
@Skn0tt
Copy link
Member

Skn0tt commented Mar 30, 2022

Hi @alii! Would you be interested in contributing a fix for this? You should be able to add a test case for this in here: https://github.com/blitz-js/babel-plugin-superjson-next/tree/main/test

@alii
Copy link
Author

alii commented Apr 1, 2022

Can certainly have a go, but I've never written a babel plugin before. Learning time!

@alii alii linked a pull request Apr 1, 2022 that will close this issue
@Skn0tt
Copy link
Member

Skn0tt commented Apr 1, 2022

love it! feel free to shoot me a question if you're stuck :)

@apieceofbart
Copy link

apieceofbart commented Sep 19, 2022

For a quick hack you can just manually add superjson like so (until the PR is merged):

import { getServerSideProps } from "./getServerSideProps";

import { withSuperJSONPage as _withSuperJSONPage } from "babel-plugin-superjson-next/tools";
import { withSuperJSONProps as _withSuperJSONProps } from "babel-plugin-superjson-next/tools";

const getServerSidePropsWithSuperJSONProps =
  _withSuperJSONProps(getServerSideProps);
  
function Page() {
...


export { getServerSidePropsWithSuperJSONProps as getServerSideProps };

export default _withSuperJSONPage(Page);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants