未验证 提交 8eb813a6 编写于 作者: T Tim Neutkens 提交者: GitHub

await config (#6488)

* await config

* update config-promise-error test

* Actually update test
上级 330bedac
...@@ -56,14 +56,14 @@ export default async function build(dir: string, conf = null): Promise<void> { ...@@ -56,14 +56,14 @@ export default async function build(dir: string, conf = null): Promise<void> {
const pages = createPagesMapping(pagePaths, config.pageExtensions) const pages = createPagesMapping(pagePaths, config.pageExtensions)
const entrypoints = createEntrypoints(pages, config.target, buildId, config) const entrypoints = createEntrypoints(pages, config.target, buildId, config)
const configs = [ const configs = [
getBaseWebpackConfig(dir, { await getBaseWebpackConfig(dir, {
buildId, buildId,
isServer: false, isServer: false,
config, config,
target: config.target, target: config.target,
entrypoints: entrypoints.client, entrypoints: entrypoints.client,
}), }),
getBaseWebpackConfig(dir, { await getBaseWebpackConfig(dir, {
buildId, buildId,
isServer: true, isServer: true,
config, config,
......
...@@ -299,9 +299,7 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, isServe ...@@ -299,9 +299,7 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, isServe
// @ts-ignore: Property 'then' does not exist on type 'Configuration' // @ts-ignore: Property 'then' does not exist on type 'Configuration'
if (typeof webpackConfig.then === 'function') { if (typeof webpackConfig.then === 'function') {
throw new Error( console.warn('> Promise returned in next config. https://err.sh/zeit/next.js/promise-in-next-config.md')
'> Promise returned in next config. https://err.sh/zeit/next.js/promise-in-next-config.md'
)
} }
} }
......
...@@ -30,8 +30,9 @@ describe('Promise in next config', () => { ...@@ -30,8 +30,9 @@ describe('Promise in next config', () => {
expect(stderr).toMatch(/Error: > Promise returned in next config\. https:\/\/err\.sh\/zeit\/next\.js\/promise-in-next-config\.md/) expect(stderr).toMatch(/Error: > Promise returned in next config\. https:\/\/err\.sh\/zeit\/next\.js\/promise-in-next-config\.md/)
}) })
it('should throw error when a promise is returned on webpack', async () => { it('should warn when a promise is returned on webpack', async () => {
configFile.write(` configFile.write(`
setTimeout(() => process.exit(0), 2 * 1000)
module.exports = (phase, { isServer }) => { module.exports = (phase, { isServer }) => {
return { return {
webpack: async (config) => { webpack: async (config) => {
...@@ -46,6 +47,6 @@ describe('Promise in next config', () => { ...@@ -46,6 +47,6 @@ describe('Promise in next config', () => {
{ stderr: true } { stderr: true }
) )
expect(stderr).toMatch(/Error: > Promise returned in next config\. https:\/\/err\.sh\/zeit\/next\.js\/promise-in-next-config\.md/) expect(stderr).toMatch(/> Promise returned in next config\. https:\/\/err\.sh\/zeit\/next\.js\/promise-in-next-config\.md/)
}) })
}) })
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册