Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default entries to main.js #1343

Merged
merged 1 commit into from
Mar 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions server/build/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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`
}
}

Expand Down
6 changes: 1 addition & 5 deletions server/on-demand-entry-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down