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() {
const Component = ComponentInfo.default
export default Component
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 _app = App
export async function renderReqToHTML(req, res, fromExport) {
......
/* eslint-env jest */
/* global jasmine */
import fs from 'fs-extra'
import { join } from 'path'
import { nextBuild } from 'next-test-utils'
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 2
const appDir = join(__dirname, '..')
const nextConfig = join(appDir, 'next.config.js')
describe('Legacy Prerender', () => {
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 })
expect(out.stderr).toMatch(`Build error occurred`)
expect(out.stderr).toMatch(
'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