Unverified Commit 649b4170 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Add deprecation note for target (#30200)

* Add deprecation note for target

* Apply suggestions from code review
Co-authored-by: 's avatarSteven <steven@ceriously.com>

* Mention Vercel leverages the traces
Co-authored-by: 's avatarSteven <steven@ceriously.com>
parent 93e3c378
# Deprecated target config
#### Why This Error Occurred
The `target` property in `next.config.js` has been deprecated. Please migrate to leverage the default target instead.
#### Possible Ways to Fix It
For serverless cases, leverage the new output file traces or deploy your application somewhere where they are leveraged automatically like [Vercel](https://vercel.com).
### Useful Links
- [Output File Tracing Documentation](https://nextjs.org/docs/messages/deprecated-target-config)
......@@ -8,6 +8,10 @@
"title": "beta-middleware",
"path": "/errors/beta-middleware.md"
},
{
"title": "deprecated-target-config",
"path": "/errors/deprecated-target-config.md"
},
{
"title": "custom-document-image-import",
"path": "/errors/custom-document-image-import.md"
......
......@@ -575,6 +575,13 @@ export default async function loadConfig(
)
}
if (userConfig.target && userConfig.target !== 'server') {
Log.warn(
'The `target` config is deprecated and will be removed in a future version.\n' +
'See more info here https://nextjs.org/docs/messages/deprecated-target-config'
)
}
if (userConfig.amp?.canonicalBase) {
const { canonicalBase } = userConfig.amp || ({} as any)
userConfig.amp = userConfig.amp || {}
......
......@@ -57,6 +57,12 @@ describe('Production Usage', () => {
await killApp(app)
})
it('should not show target deprecation warning', () => {
expect(output).not.toContain(
'The `target` config is deprecated and will be removed in a future version'
)
})
it('should contain generated page count in output', async () => {
const pageCount = 40
expect(output).toContain(`Generating static pages (0/${pageCount})`)
......
......@@ -26,8 +26,14 @@ let appPort
let app
describe('Serverless', () => {
let output
beforeAll(async () => {
await nextBuild(appDir)
const result = await nextBuild(appDir, undefined, {
stderr: true,
stdout: true,
})
output = result.stdout + result.stderr
appPort = await findPort()
app = await nextStart(appDir, appPort, {
onStderr: (msg) => {
......@@ -37,6 +43,12 @@ describe('Serverless', () => {
})
afterAll(() => killApp(app))
it('should show target config deprecation warning', () => {
expect(output).toContain(
'The `target` config is deprecated and will be removed in a future version'
)
})
it('should render the page', async () => {
const html = await renderViaHTTP(appPort, '/')
expect(html).toMatch(/Hello World/)
......
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