Unverified Commit 9ec3dae6 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Fix next/config module mismatch in new serverless mode (#10792)

* Add failing test case

* Update serverless-loader require to fix config module mismatch
Co-authored-by: 's avatarJoe Haddad <timer150@gmail.com>
parent 2b74db73
......@@ -62,7 +62,7 @@ const nextServerlessLoader: loader.Loader = function() {
const runtimeConfigImports = runtimeConfig
? `
const { setConfig } = require('next/dist/next-server/lib/runtime-config')
const { setConfig } = require('next/config')
`
: ''
......
......@@ -31,15 +31,16 @@ const nextStart = async (appDir, appPort) => {
)
}
describe('Serverless runtime configs', () => {
beforeAll(() => cleanUp())
afterAll(() => cleanUp())
const runTests = (oldServerless = false) => {
const serverlessMode = oldServerless
? 'serverless'
: 'experimental-serverless-trace'
it('should not error on usage of publicRuntimeConfig', async () => {
await fs.writeFile(
nextConfigPath,
`module.exports = {
target: 'serverless',
target: '${serverlessMode}',
publicRuntimeConfig: {
hello: 'world'
}
......@@ -59,7 +60,7 @@ describe('Serverless runtime configs', () => {
await fs.writeFile(
nextConfigPath,
`module.exports = {
target: 'serverless',
target: '${serverlessMode}',
serverRuntimeConfig: {
hello: 'world'
}
......@@ -130,7 +131,7 @@ describe('Serverless runtime configs', () => {
await fs.writeFile(
nextConfigPath,
`module.exports = {
target: 'serverless',
target: '${serverlessMode}',
serverRuntimeConfig: {
hello: 'world'
},
......@@ -150,7 +151,7 @@ describe('Serverless runtime configs', () => {
await fs.writeFile(
nextConfigPath,
`module.exports = {
target: 'serverless',
target: '${serverlessMode}',
serverRuntimeConfig: {
hello: 'world'
},
......@@ -164,4 +165,17 @@ describe('Serverless runtime configs', () => {
const app = await launchApp(appDir, appPort)
await testRuntimeConfig(app, appPort)
})
}
describe('Serverless runtime configs', () => {
beforeAll(() => cleanUp())
afterAll(() => cleanUp())
describe('legacy serverless mode', () => {
runTests(true)
})
describe('experimental-serverless-trace mode', () => {
runTests()
})
})
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