Unverified Commit 58cc1d3b authored by Joe Haddad's avatar Joe Haddad Committed by GitHub

Remove static optimization from message (#9045)

* Remove static optimization from message
This check does not pertain to automatic static optimization.

Closes https://github.com/zeit/next.js/issues/9042

* Update help message
parent a3b990a5
......@@ -2,8 +2,15 @@
#### Why This Error Occurred
While auto exporting a page a valid React Component wasn't found. This could mean you have a file in `pages` that exports something that is not a React Component.
A page that does not export a valid React Component was found while analyzing the build output.
This is a hard error because the page would error when rendered, and causes poor build performance.
#### Possible Ways to Fix It
Move any non-page files that don't export a React Component as the default export to a different folder like `components` or `lib`.
Investigate the list of page(s) specified in the error message.
For each, you'll want to check if the file is meant to be a page.
If the file is not meant to be a page, and instead, is a shared component or file, move the file to a different folder like `components` or `lib`.
If the file is meant to be a page, double check you have an `export default` with the React Component instead of an `export`. If you're already using `export default`, make sure the returned valid is a valid React Component.
......@@ -411,7 +411,7 @@ export default async function build(dir: string, conf = null): Promise<void> {
if (invalidPages.size > 0) {
throw new Error(
`automatic static optimization failed: found page${
`Build optimization failed: found page${
invalidPages.size === 1 ? '' : 's'
} without a React Component as default export in \n${[...invalidPages]
.map(pg => `pages${pg}`)
......
......@@ -11,7 +11,7 @@ describe('Invalid Page automatic static optimization', () => {
const { stderr } = await nextBuild(appDir, [], { stderr: true })
expect(stderr).toMatch(
/automatic static optimization failed: found pages without a React Component as default export in/
/Build optimization failed: found pages without a React Component as default export in/
)
expect(stderr).toMatch(/pages\/invalid/)
expect(stderr).toMatch(/pages\/also-invalid/)
......
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