Skip to content

Commit

Permalink
Wait for entry to resolve in production build (#7104)
Browse files Browse the repository at this point in the history
* Wait for entry to resolve in production build

* Return promise
  • Loading branch information
timneutkens authored Apr 22, 2019
1 parent d2b0db8 commit c0a10b9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion packages/next/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { importAutoDllPlugin } from './webpack/plugins/dll-import'
import { WebpackEntrypoints } from './entries'
type ExcludesFalse = <T>(x: T | false) => x is T

export default function getBaseWebpackConfig (dir: string, {dev = false, debug = false, isServer = false, buildId, config, target = 'server', entrypoints, selectivePageBuilding = false, selectivePageBuildingCacheIdentifier = ''}: {dev?: boolean, debug?: boolean, isServer?: boolean, buildId: string, config: any, target?: string, entrypoints: WebpackEntrypoints, selectivePageBuilding?: boolean, selectivePageBuildingCacheIdentifier?: string}): webpack.Configuration {
export default async function getBaseWebpackConfig (dir: string, {dev = false, debug = false, isServer = false, buildId, config, target = 'server', entrypoints, selectivePageBuilding = false, selectivePageBuildingCacheIdentifier = ''}: {dev?: boolean, debug?: boolean, isServer?: boolean, buildId: string, config: any, target?: string, entrypoints: WebpackEntrypoints, selectivePageBuilding?: boolean, selectivePageBuildingCacheIdentifier?: string}): Promise<webpack.Configuration> {
const distDir = path.join(dir, config.distDir)
const defaultLoaders = {
babel: {
Expand Down Expand Up @@ -375,5 +375,10 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, debug =
}
}

if(!dev) {
// @ts-ignore entry is always a function
webpackConfig.entry = await webpackConfig.entry()
}

return webpackConfig
}
4 changes: 2 additions & 2 deletions packages/next/server/hot-reloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ export default class HotReloader {
let additionalClientEntrypoints = {}
additionalClientEntrypoints[CLIENT_STATIC_FILES_RUNTIME_AMP] = `.${sep}` + relativePath(this.dir, join(NEXT_PROJECT_ROOT_DIST_CLIENT, 'amp-dev'))

return [
return Promise.all([
getBaseWebpackConfig(this.dir, { dev: true, isServer: false, config: this.config, buildId: this.buildId, entrypoints: { ...entrypoints.client, ...additionalClientEntrypoints } }),
getBaseWebpackConfig(this.dir, { dev: true, isServer: true, config: this.config, buildId: this.buildId, entrypoints: entrypoints.server })
]
])
}

async start () {
Expand Down

0 comments on commit c0a10b9

Please sign in to comment.