Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[build] validate the exported config values (#38370)
Right now if people will accidentally export a typo like `runtime: 'experimental-egde'` we will fail silently. This commit ensures we will throw and fail loudly when such typos occur. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md`
- Loading branch information
Showing
4 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
test/production/exported-runtimes-value-validation/app/pages/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function Page() { | ||
return <p>hello world</p> | ||
} | ||
|
||
export const config = { | ||
runtime: 'something-odd', | ||
} |
18 changes: 18 additions & 0 deletions
18
test/production/exported-runtimes-value-validation/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { nextBuild } from 'next-test-utils' | ||
import path from 'path' | ||
|
||
describe('Exported runtimes value validation', () => { | ||
test('fails to build on malformed input', async () => { | ||
const result = await nextBuild( | ||
path.resolve(__dirname, './app'), | ||
undefined, | ||
{ stdout: true, stderr: true } | ||
) | ||
expect(result).toMatchObject({ | ||
code: 1, | ||
stderr: expect.stringContaining( | ||
`Provided runtime "something-odd" is not supported.` | ||
), | ||
}) | ||
}) | ||
}) |