Skip to content

Commit

Permalink
fix: 9919 no exported config found
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrika committed Jan 23, 2020
1 parent 53e9983 commit 1418998
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/next/next-server/server/config.ts
Expand Up @@ -228,6 +228,14 @@ export default function loadConfig(
phase,
userConfigModule.default || userConfigModule
)

if (Object.keys(userConfig).length === 0) {
console.warn(
chalk.yellow.bold('Warning: ') +
'Detected next.config.js, no exported configuration found.'
)
}

if (userConfig.target && !targets.includes(userConfig.target)) {
throw new Error(
`Specified target is invalid. Provided: "${
Expand Down
3 changes: 3 additions & 0 deletions test/isolated/_resolvedata/no-export/next.config.js
@@ -0,0 +1,3 @@
// eslint-disable-next-line no-lone-blocks
{
}
15 changes: 15 additions & 0 deletions test/isolated/config.test.js
Expand Up @@ -108,4 +108,19 @@ describe('config', () => {
)
expect(config.__test__ext).toBe('js')
})

it('Should log a warning when no exported configuration found', () => {
const spy = jest.spyOn(console, 'warn')

loadConfig(
PHASE_DEVELOPMENT_SERVER,
join(__dirname, '_resolvedata', 'no-export')
)

expect(spy.mock.calls[0][0]).toMatch(
'Detected next.config.js, no exported configuration found'
)

spy.mockRestore()
})
})

0 comments on commit 1418998

Please sign in to comment.