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() { ...@@ -62,7 +62,7 @@ const nextServerlessLoader: loader.Loader = function() {
const runtimeConfigImports = runtimeConfig 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) => { ...@@ -31,15 +31,16 @@ const nextStart = async (appDir, appPort) => {
) )
} }
describe('Serverless runtime configs', () => { const runTests = (oldServerless = false) => {
beforeAll(() => cleanUp()) const serverlessMode = oldServerless
afterAll(() => cleanUp()) ? 'serverless'
: 'experimental-serverless-trace'
it('should not error on usage of publicRuntimeConfig', async () => { it('should not error on usage of publicRuntimeConfig', async () => {
await fs.writeFile( await fs.writeFile(
nextConfigPath, nextConfigPath,
`module.exports = { `module.exports = {
target: 'serverless', target: '${serverlessMode}',
publicRuntimeConfig: { publicRuntimeConfig: {
hello: 'world' hello: 'world'
} }
...@@ -59,7 +60,7 @@ describe('Serverless runtime configs', () => { ...@@ -59,7 +60,7 @@ describe('Serverless runtime configs', () => {
await fs.writeFile( await fs.writeFile(
nextConfigPath, nextConfigPath,
`module.exports = { `module.exports = {
target: 'serverless', target: '${serverlessMode}',
serverRuntimeConfig: { serverRuntimeConfig: {
hello: 'world' hello: 'world'
} }
...@@ -130,7 +131,7 @@ describe('Serverless runtime configs', () => { ...@@ -130,7 +131,7 @@ describe('Serverless runtime configs', () => {
await fs.writeFile( await fs.writeFile(
nextConfigPath, nextConfigPath,
`module.exports = { `module.exports = {
target: 'serverless', target: '${serverlessMode}',
serverRuntimeConfig: { serverRuntimeConfig: {
hello: 'world' hello: 'world'
}, },
...@@ -150,7 +151,7 @@ describe('Serverless runtime configs', () => { ...@@ -150,7 +151,7 @@ describe('Serverless runtime configs', () => {
await fs.writeFile( await fs.writeFile(
nextConfigPath, nextConfigPath,
`module.exports = { `module.exports = {
target: 'serverless', target: '${serverlessMode}',
serverRuntimeConfig: { serverRuntimeConfig: {
hello: 'world' hello: 'world'
}, },
...@@ -164,4 +165,17 @@ describe('Serverless runtime configs', () => { ...@@ -164,4 +165,17 @@ describe('Serverless runtime configs', () => {
const app = await launchApp(appDir, appPort) const app = await launchApp(appDir, appPort)
await testRuntimeConfig(app, 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