forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 9919 Add warning when no config is exported from next.con… (verc…
…el#10228) * fix: 9919 no exported config found * fix: 9919 remove isolated test, add integration * fix: 9919 add check for successfull compilation and fix warnin check * Add test for development output * fix: 9919 add error page and link to it in warning * Update empty-configuration.md Co-authored-by: JJ Kasper <jj@jjsweb.site> Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
- Loading branch information
Showing
5 changed files
with
78 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Detected next.config.js, no exported configuration found | ||
|
||
#### Why This Warning Occurred | ||
|
||
There is no object exported from next.config.js or the object is empty. | ||
|
||
#### Possible Ways to Fix It | ||
|
||
Check if you correctly export configuration in `next.config.js` file: | ||
|
||
``` | ||
module.exports = { | ||
/* config options here */ | ||
} | ||
``` | ||
|
||
### Useful Links | ||
|
||
- [Introduction to next.config.js](https://nextjs.org/docs/api-reference/next.config.js/introduction) |
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,6 @@ | ||
/* eslint-disable */ | ||
{ | ||
experimental: { | ||
basePath: '/docs' | ||
} | ||
} |
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 @@ | ||
export default () => <div>Hello World</div> |
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,44 @@ | ||
/* eslint-env jest */ | ||
/* global jasmine */ | ||
import { join } from 'path' | ||
import { | ||
nextBuild, | ||
launchApp, | ||
findPort, | ||
killApp, | ||
waitFor, | ||
} from 'next-test-utils' | ||
|
||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 2 | ||
|
||
const appDir = join(__dirname, '..') | ||
|
||
describe('Empty configuration', () => { | ||
it('should show relevant warning and compile successfully for next build', async () => { | ||
const { stderr, stdout } = await nextBuild(appDir, [], { | ||
stderr: true, | ||
stdout: true, | ||
}) | ||
expect(stdout).toMatch(/Compiled successfully./) | ||
expect(stderr).toMatch( | ||
/Warning: Detected next.config.js, no exported configuration found. https:\/\/err.sh\/zeit\/next.js\/empty-configuration/ | ||
) | ||
}) | ||
|
||
it('should show relevant warning and compile successfully for next dev', async () => { | ||
let stderr = '' | ||
|
||
const appPort = await findPort() | ||
const app = await launchApp(appDir, appPort, { | ||
onStderr(msg) { | ||
stderr += msg || '' | ||
}, | ||
}) | ||
await waitFor(1000) | ||
await killApp(app) | ||
|
||
expect(stderr).toMatch( | ||
/Warning: Detected next.config.js, no exported configuration found. https:\/\/err.sh\/zeit\/next.js\/empty-configuration/ | ||
) | ||
}) | ||
}) |