Commit 83eeda08 authored by JJ Kasper's avatar JJ Kasper Committed by Joe Haddad

Fix not detecting legacy getStaticParams in serverless mode (#9685)

* Fix not detecting legacy getStaticParams in serverless mode

* Update test/integration/prerender-legacy/test/index.test.js
parent da1ef506
...@@ -99,12 +99,9 @@ const nextServerlessLoader: loader.Loader = function() { ...@@ -99,12 +99,9 @@ const nextServerlessLoader: loader.Loader = function() {
const Component = ComponentInfo.default const Component = ComponentInfo.default
export default Component export default Component
export const unstable_getStaticProps = ComponentInfo['unstable_getStaticProp' + 's'] export const unstable_getStaticProps = ComponentInfo['unstable_getStaticProp' + 's']
export const unstable_getStaticParams = ComponentInfo['unstable_getStaticParam' + 's']
export const unstable_getStaticPaths = ComponentInfo['unstable_getStaticPath' + 's']
${
isDynamicRoute(page)
? "export const unstable_getStaticPaths = ComponentInfo['unstable_getStaticPath' + 's']"
: 'export const unstable_getStaticPaths = undefined'
}
export const config = ComponentInfo['confi' + 'g'] || {} export const config = ComponentInfo['confi' + 'g'] || {}
export const _app = App export const _app = App
export async function renderReqToHTML(req, res, fromExport) { export async function renderReqToHTML(req, res, fromExport) {
......
/* eslint-env jest */ /* eslint-env jest */
/* global jasmine */ /* global jasmine */
import fs from 'fs-extra'
import { join } from 'path' import { join } from 'path'
import { nextBuild } from 'next-test-utils' import { nextBuild } from 'next-test-utils'
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 2 jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 2
const appDir = join(__dirname, '..') const appDir = join(__dirname, '..')
const nextConfig = join(appDir, 'next.config.js')
describe('Legacy Prerender', () => { describe('Legacy Prerender', () => {
describe('handles old getStaticParams', () => { describe('handles old getStaticParams', () => {
it('should fail the build', async () => { it('should fail the build in server mode', async () => {
const out = await nextBuild(appDir, [], { stderr: true }) const out = await nextBuild(appDir, [], { stderr: true })
expect(out.stderr).toMatch(`Build error occurred`) expect(out.stderr).toMatch(`Build error occurred`)
expect(out.stderr).toMatch( expect(out.stderr).toMatch(
'unstable_getStaticParams was replaced with unstable_getStaticPaths. Please update your code.' 'unstable_getStaticParams was replaced with unstable_getStaticPaths. Please update your code.'
) )
}) })
it('should fail the build in serverless mode', async () => {
await fs.writeFile(
nextConfig,
`module.exports = { target: 'serverless' }`
)
const out = await nextBuild(appDir, [], { stderr: true })
await fs.remove(nextConfig)
expect(out.stderr).toMatch(`Build error occurred`)
expect(out.stderr).toMatch(
'unstable_getStaticParams was replaced with unstable_getStaticPaths. Please update your code.'
)
})
}) })
}) })
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