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