Unverified Commit 06b6aa2f authored by Hannes Bornö's avatar Hannes Bornö Committed by GitHub

Error when exporting AMP config in app dir (#45228)

Errors in app-render if an exported amp config is found.

Fixes NEXT-223

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] [e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
parent dff39acc
......@@ -1373,6 +1373,12 @@ export async function renderToHTMLOrFlight(
`The default export of notFound is not a React Component in ${segment}`
)
}
if (layoutOrPageMod?.config?.amp) {
throw new Error(
'AMP is not supported in the app directory. If you need to use AMP it will continue to be supported in the pages directory.'
)
}
}
// Handle dynamic segment params.
......
/* eslint-env jest */
import { sandbox } from './helpers'
import { createNextDescribe, FileRef } from 'e2e-utils'
import path from 'path'
createNextDescribe(
'Error Overlay unsupported app features',
{
files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')),
dependencies: {
react: 'latest',
'react-dom': 'latest',
},
skipStart: true,
},
({ next }) => {
it('should show error exporting AMP config in app dir', async () => {
const { session, cleanup } = await sandbox(next)
// Add AMP exprot
await session.patch(
'app/page.js',
`
export const config = { amp: true }
import Component from '../index'
export default function Page() {
return <Component />
}
`
)
await session.hasRedbox(true)
expect(await session.getRedboxDescription()).toInclude(
'AMP is not supported in the app directory. If you need to use AMP it will continue to be supported in the pages directory.'
)
await cleanup()
})
}
)
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