-
Notifications
You must be signed in to change notification settings - Fork 27.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
## Bug - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` Fixes #38743. Fixes: #38750 The PR adds basic `TemplateLiteral` support for static analysis. The corresponding re-production of #38743 has also been implemented in e2e tests.
- Loading branch information
Showing
8 changed files
with
212 additions
and
40 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,119 @@ | ||
# Invalid Page Config | ||
# Invalid Page / API Route Config | ||
|
||
#### Why This Error Occurred | ||
|
||
In one of your pages you did `export const config` with an invalid value. | ||
In one of your pages or API Routes you did `export const config` with an invalid value. | ||
|
||
#### Possible Ways to Fix It | ||
|
||
The page's config must be an object initialized directly when being exported and not modified dynamically. | ||
The config object must only contains static constant literals without expressions. | ||
|
||
This is not allowed | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>Not Allowed</th> | ||
<th>Allowed</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
|
||
<tr> | ||
<td> | ||
|
||
```js | ||
// `config` should be an object | ||
export const config = 'hello world' | ||
``` | ||
|
||
This is not allowed | ||
</td> | ||
<td> | ||
|
||
```js | ||
export const config = {} | ||
``` | ||
|
||
</td> | ||
</tr> | ||
|
||
<tr> | ||
<td> | ||
|
||
```js | ||
const config = {} | ||
export const config = {} | ||
// `config.amp` is defined after `config` is exported | ||
config.amp = true | ||
|
||
// `config.amp` contains a dynamic expression | ||
export const config = { | ||
amp: 1 + 1 > 2, | ||
} | ||
``` | ||
|
||
</td> | ||
<td> | ||
|
||
```js | ||
export const config = { | ||
amp: true, | ||
} | ||
|
||
export const config = { | ||
amp: false, | ||
} | ||
``` | ||
|
||
This is not allowed | ||
</td> | ||
</tr> | ||
|
||
<tr> | ||
<td> | ||
|
||
```js | ||
// `config.runtime` contains a dynamic expression | ||
export const config = { | ||
runtime: `node${'js'}`, | ||
} | ||
``` | ||
|
||
</td> | ||
<td> | ||
|
||
```js | ||
export const config = { | ||
runtime: 'nodejs', | ||
} | ||
export const config = { | ||
runtime: `nodejs`, | ||
} | ||
``` | ||
|
||
</td> | ||
</tr> | ||
|
||
<tr> | ||
<td> | ||
|
||
```js | ||
// Re-exported `config` is not allowed | ||
export { config } from '../config' | ||
``` | ||
|
||
This is allowed | ||
</td> | ||
<td> | ||
|
||
```js | ||
export const config = { amp: true } | ||
export const config = {} | ||
``` | ||
|
||
</td> | ||
</tr> | ||
|
||
</tbody> | ||
</table> | ||
|
||
### Useful Links | ||
|
||
- [Enabling AMP Support](https://nextjs.org/docs/advanced-features/amp-support/introduction) | ||
- [API Middlewares](https://nextjs.org/docs/api-routes/api-middlewares) | ||
- [Switchable Runtime](https://nextjs.org/docs/advanced-features/react-18/switchable-runtime) |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default (req) => { | ||
return new Response(`Returned by Edge API Route ${req.url}`) | ||
} | ||
|
||
export const config = { | ||
runtime: `experimental-edge`, | ||
} |
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
File renamed without changes.
7 changes: 7 additions & 0 deletions
7
test/production/exported-runtimes-value-validation/unsupported-syntax/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-${'real' + 1 + 'y odd'}`, | ||
} |