Unverified Commit dabeb51f authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Fix SSG query with experimental-compile (#56680)

Ensures query isn't omitted when using experimental compile mode with SSG pages as it skips the isReady delay that is normally done with prerendering. 
parent d73b8366
......@@ -941,7 +941,7 @@ export default async function build(
? path.relative(distDir, incrementalCacheHandlerPath)
: undefined,
isExperimentalCompile: true,
isExperimentalCompile: isCompile,
},
},
appDir: dir,
......
......@@ -688,7 +688,8 @@ export default class NextNodeServer extends BaseServer {
return {
components,
query: {
...(components.getStaticProps
...(!this.renderOpts.isExperimentalCompile &&
components.getStaticProps
? ({
amp: query.amp,
__nextDataReq: query.__nextDataReq,
......
......@@ -199,7 +199,7 @@ export class NextServer {
)).config
// @ts-expect-error internal field
config.experimental.isExperimentalConfig =
config.experimental.isExperimentalCompile =
serializedConfig.experimental.isExperimentalCompile
} catch (_) {
// if distDir is customized we don't know until we
......
......@@ -14,6 +14,16 @@ createNextDescribe(
: undefined,
},
({ next, isNextDev: isDev, isNextStart, isNextDeploy }) => {
if (process.env.NEXT_EXPERIMENTAL_COMPILE) {
it('should provide query for getStaticProps page correctly', async () => {
const res = await next.fetch('/ssg?hello=world')
expect(res.status).toBe(200)
const $ = cheerio.load(await res.text())
expect(JSON.parse($('#query').text())).toEqual({ hello: 'world' })
})
}
if (isNextStart && !process.env.NEXT_EXPERIMENTAL_COMPILE) {
it('should not have loader generated function for edge runtime', async () => {
expect(
......
import { useRouter } from 'next/router'
export default function Page(props) {
return (
<>
<p>hello from ssg</p>
<p id="query">{JSON.stringify(useRouter().query)}</p>
</>
)
}
export function getStaticProps() {
return {
props: {},
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment