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

Fix bug with getServerSideProps when swcLoader is enabled #29760

Merged
merged 11 commits into from
Oct 9, 2021
6 changes: 1 addition & 5 deletions packages/next/build/swc/src/next_ssg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,10 @@ impl State {
"getStaticProps",
"getStaticPaths",
"getServerSideProps",
"unstable_getStaticProps",
"unstable_getStaticPaths",
"unstable_getServerProps",
"unstable_getServerSideProps",
];

if ssg_exports.contains(&&*i.sym) {
if &*i.sym == "" {
if &*i.sym == "getServerSideProps" {
if self.is_prerenderer {
panic!(
"You can not use getStaticProps or getStaticPaths with \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import fs from 'fs'
import other from 'other'

const [a, b, ...rest] = fs.promises
const [foo, bar] = other

export async function getServerSideProps() {
a
b
rest
bar
}
export default function Home() {
return <div />
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import other from "other";
const [foo] = other;
export var __N_SSP = true;
export default function Home() {
return __jsx("div", null);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export async function getServerSideProps({ query }) {
return { props: { prop: query.prop } };
}

export default function GspPage({ prop }) {
return <div id="prop">{prop}</div>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export var __N_SSP = true;
export default function GspPage({ prop }) {
return __jsx("div", {
id: "prop"
}, prop);
}
Loading