Unverified Commit c0a10b99 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Wait for entry to resolve in production build (#7104)

* Wait for entry to resolve in production build

* Return promise
parent d2b0db81
...@@ -20,7 +20,7 @@ import { importAutoDllPlugin } from './webpack/plugins/dll-import' ...@@ -20,7 +20,7 @@ import { importAutoDllPlugin } from './webpack/plugins/dll-import'
import { WebpackEntrypoints } from './entries' import { WebpackEntrypoints } from './entries'
type ExcludesFalse = <T>(x: T | false) => x is T 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 distDir = path.join(dir, config.distDir)
const defaultLoaders = { const defaultLoaders = {
babel: { babel: {
...@@ -375,5 +375,10 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, debug = ...@@ -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 return webpackConfig
} }
...@@ -175,10 +175,10 @@ export default class HotReloader { ...@@ -175,10 +175,10 @@ export default class HotReloader {
let additionalClientEntrypoints = {} let additionalClientEntrypoints = {}
additionalClientEntrypoints[CLIENT_STATIC_FILES_RUNTIME_AMP] = `.${sep}` + relativePath(this.dir, join(NEXT_PROJECT_ROOT_DIST_CLIENT, 'amp-dev')) 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: 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 }) getBaseWebpackConfig(this.dir, { dev: true, isServer: true, config: this.config, buildId: this.buildId, entrypoints: entrypoints.server })
] ])
} }
async start () { async start () {
......
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