3a87f0005e
Currently we are validating the `experimental.serverActions` flag when creating the actual entries for Server Actions, this causes two problems. One is that syntax errors caught at compilation time are still shown, even if you don't have this flag enabled. Another problem is we still traverse the client graph to collect these action modules even if the flag isn't enabled. This PR moves that check to be happening at compilation time, which addresses the two above but also brings the extra benefit of showing the exact span and module trace that errors: <img width="974" alt="CleanShot 2023-07-03 at 20 26 34@2x" src="https://github.com/vercel/next.js/assets/3676859/1676b1f6-e205-4963-bce4-5b515a698e9c">
41 lines
863 B
TypeScript
41 lines
863 B
TypeScript
import { createNextDescribe } from 'e2e-utils'
|
|
|
|
createNextDescribe(
|
|
'app-dir action invalid config',
|
|
{
|
|
files: __dirname,
|
|
skipDeployment: true,
|
|
dependencies: {
|
|
react: 'latest',
|
|
'react-dom': 'latest',
|
|
'server-only': 'latest',
|
|
},
|
|
},
|
|
({ next, isNextStart }) => {
|
|
if (!isNextStart) {
|
|
it('skip test for dev mode', () => {})
|
|
return
|
|
}
|
|
|
|
beforeAll(async () => {
|
|
await next.stop()
|
|
await next.patchFile(
|
|
'next.config.js',
|
|
`
|
|
module.exports = {
|
|
experimental: {},
|
|
}
|
|
`
|
|
)
|
|
try {
|
|
await next.build()
|
|
} catch {}
|
|
})
|
|
|
|
it('should error if serverActions is not enabled', async () => {
|
|
expect(next.cliOutput).toContain(
|
|
'To use Server Actions, please enable the feature flag in your Next.js config.'
|
|
)
|
|
})
|
|
}
|
|
)
|