Unverified Commit c2229a3a authored by Damien Simonin Feugas's avatar Damien Simonin Feugas Committed by GitHub

chore: addresses leftover from #44045 (#44080)

## 📖 What's in there?

Yesterday we didn't had time to address leftovers from #44045.
Here it is.

- [ ] 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 (from [PR
43814](https://github.com/vercel/next.js/pull/43814))
- [ ] 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)

## 🧪  How to test?

Several tests cases added:
- in dev mode, errors and warning: `NEXT_TEST_MODE=dev pnpm testheadless
--testPathPattern edge-configurable-runtime`
- in build mode, build error for pages on the `edge`:
`NEXT_TEST_MODE=start pnpm testheadless --testPathPattern
edge-configurable-runtime`
Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
parent 599ca813
...@@ -313,17 +313,14 @@ export async function getPageStaticInfo(params: { ...@@ -313,17 +313,14 @@ export async function getPageStaticInfo(params: {
!isEdgeRuntime(resolvedRuntime) !isEdgeRuntime(resolvedRuntime)
) { ) {
const options = Object.values(SERVER_RUNTIME).join(', ') const options = Object.values(SERVER_RUNTIME).join(', ')
if (typeof resolvedRuntime !== 'string') { const message =
Log.error( typeof resolvedRuntime !== 'string'
`The \`runtime\` config must be a string. Please leave it empty or choose one of: ${options}` ? `The \`runtime\` config must be a string. Please leave it empty or choose one of: ${options}`
) : `Provided runtime "${resolvedRuntime}" is not supported. Please leave it empty or choose one of: ${options}`
if (isDev) {
Log.error(message)
} else { } else {
Log.error( throw new Error(message)
`Provided runtime "${resolvedRuntime}" is not supported. Please leave it empty or choose one of: ${options}`
)
}
if (!isDev) {
process.exit(1)
} }
} }
...@@ -346,10 +343,10 @@ export async function getPageStaticInfo(params: { ...@@ -346,10 +343,10 @@ export async function getPageStaticInfo(params: {
!isAPIRoute(page.replace(/^\/pages\//, '/')) !isAPIRoute(page.replace(/^\/pages\//, '/'))
) { ) {
const message = `Page ${page} provided runtime 'edge', the edge runtime for rendering is currently experimental. Use runtime 'experimental-edge' instead.` const message = `Page ${page} provided runtime 'edge', the edge runtime for rendering is currently experimental. Use runtime 'experimental-edge' instead.`
Log.error(message) if (isDev) {
Log.error(message)
if (!isDev) { } else {
process.exit(1) throw new Error(message)
} }
} }
......
...@@ -122,7 +122,7 @@ describe('Configurable runtime for pages and API routes', () => { ...@@ -122,7 +122,7 @@ describe('Configurable runtime for pages and API routes', () => {
expect(output.code).toBe(1) expect(output.code).toBe(1)
expect(output.stderr).not.toContain(`Build failed`) expect(output.stderr).not.toContain(`Build failed`)
expect(output.stderr).toContain( expect(output.stderr).toContain(
`error - Page / provided runtime 'edge', the edge runtime for rendering is currently experimental. Use runtime 'experimental-edge' instead.` `Error: Page / provided runtime 'edge', the edge runtime for rendering is currently experimental. Use runtime 'experimental-edge' instead.`
) )
}) })
}) })
......
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