Unverified Commit 3edfe518 authored by Joe Haddad's avatar Joe Haddad Committed by GitHub

Strongly Type Usage of Client Pages Loader (#11985)

parent 0e915b11
......@@ -6,6 +6,7 @@ import { __ApiPreviewProps } from '../next-server/server/api-utils'
import { isTargetLikeServerless } from '../next-server/server/config'
import { normalizePagePath } from '../next-server/server/normalize-page-path'
import { warn } from './output/log'
import { ClientPagesLoaderOptions } from './webpack/loaders/next-client-pages-loader'
import { ServerlessLoaderQuery } from './webpack/loaders/next-serverless-loader'
type PagesMapping = {
......@@ -128,10 +129,13 @@ export function createEntrypoints(
}
if (!isApiRoute) {
const pageLoader = `next-client-pages-loader?${stringify({
const pageLoaderOpts: ClientPagesLoaderOptions = {
page,
absolutePagePath,
})}!`
}
const pageLoader = `next-client-pages-loader?${stringify(
pageLoaderOpts
)}!`
// Make sure next/router is a dependency of _app or else granularChunks
// might cause the router to not be able to load causing hydration
......
......@@ -6,9 +6,9 @@ import { parse } from 'url'
import webpack from 'webpack'
import WebpackDevMiddleware from 'webpack-dev-middleware'
import DynamicEntryPlugin from 'webpack/lib/DynamicEntryPlugin'
import { isWriteable } from '../build/is-writeable'
import * as Log from '../build/output/log'
import { ClientPagesLoaderOptions } from '../build/webpack/loaders/next-client-pages-loader'
import { API_ROUTE } from '../lib/constants'
import {
IS_BUNDLED_PAGE_REGEX,
......@@ -85,12 +85,13 @@ export default function onDemandEntryHandler(
}
entries[page].status = BUILDING
const pageLoaderOpts: ClientPagesLoaderOptions = {
page,
absolutePagePath,
}
return addEntry(compilation, compiler.context, name, [
compiler.name === 'client'
? `next-client-pages-loader?${stringify({
page,
absolutePagePath,
})}!`
? `next-client-pages-loader?${stringify(pageLoaderOpts)}!`
: absolutePagePath,
])
})
......
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