diff --git a/server/build/webpack.js b/server/build/webpack.js index 4f4513c96f436..dae3c8eca75d6 100644 --- a/server/build/webpack.js +++ b/server/build/webpack.js @@ -28,15 +28,22 @@ const relativeResolve = rootModuleRelativePath(require) export default async function createCompiler (dir, { dev = false, quiet = false, buildDir } = {}) { dir = resolve(dir) const config = getConfig(dir) - const defaultEntries = dev - ? [join(__dirname, '..', '..', 'client/webpack-hot-middleware-client')] : [] + const defaultEntries = dev ? [ + join(__dirname, '..', '..', 'client', 'webpack-hot-middleware-client'), + join(__dirname, '..', '..', 'client', 'on-demand-entries-client') + ] : [] const mainJS = dev ? require.resolve('../../client/next-dev') : require.resolve('../../client/next') let minChunks const entry = async () => { - const entries = { 'main.js': mainJS } + const entries = { + 'main.js': [ + ...defaultEntries, + mainJS + ] + } const pages = await glob('pages/**/*.js', { cwd: dir }) const devPages = pages.filter((p) => p === 'pages/_document.js' || p === 'pages/_error.js') @@ -45,11 +52,11 @@ export default async function createCompiler (dir, { dev = false, quiet = false, // managing pages. if (dev) { for (const p of devPages) { - entries[join('bundles', p)] = [...defaultEntries, `./${p}?entry`] + entries[join('bundles', p)] = `./${p}?entry` } } else { for (const p of pages) { - entries[join('bundles', p)] = [...defaultEntries, `./${p}?entry`] + entries[join('bundles', p)] = `./${p}?entry` } } diff --git a/server/on-demand-entry-handler.js b/server/on-demand-entry-handler.js index 0ac3ef5ead60f..79c9160b58804 100644 --- a/server/on-demand-entry-handler.js +++ b/server/on-demand-entry-handler.js @@ -71,11 +71,7 @@ export default function onDemandEntryHandler (devMiddleware, compiler, { const pathname = await resolvePath(pagePath) const name = join('bundles', pathname.substring(dir.length)) - const entry = [ - join(__dirname, '..', 'client/webpack-hot-middleware-client'), - join(__dirname, '..', 'client', 'on-demand-entries-client'), - `${pathname}?entry` - ] + const entry = `${pathname}?entry` await new Promise((resolve, reject) => { const entryInfo = entries[page]