Unverified Commit c613608b authored by Shu Ding's avatar Shu Ding Committed by GitHub

Fix client entry unexpectedly created in app dir (#37561)

fix client entry unexpectedly created
parent 0bfdf0e0
...@@ -327,6 +327,7 @@ export async function createEntrypoints(params: CreateEntrypointsParams) { ...@@ -327,6 +327,7 @@ export async function createEntrypoints(params: CreateEntrypointsParams) {
} }
const isServerComponent = serverComponentRegex.test(absolutePagePath) const isServerComponent = serverComponentRegex.test(absolutePagePath)
const isInsideAppDir = appDir && absolutePagePath.startsWith(appDir)
const staticInfo = await getPageStaticInfo({ const staticInfo = await getPageStaticInfo({
nextConfig: config, nextConfig: config,
...@@ -339,7 +340,7 @@ export async function createEntrypoints(params: CreateEntrypointsParams) { ...@@ -339,7 +340,7 @@ export async function createEntrypoints(params: CreateEntrypointsParams) {
page, page,
pageRuntime: staticInfo.runtime, pageRuntime: staticInfo.runtime,
onClient: () => { onClient: () => {
if (isServerComponent) { if (isServerComponent || isInsideAppDir) {
// We skip the initial entries for server component pages and let the // We skip the initial entries for server component pages and let the
// server compiler inject them instead. // server compiler inject them instead.
} else { } else {
......
...@@ -563,6 +563,8 @@ export default class HotReloader { ...@@ -563,6 +563,8 @@ export default class HotReloader {
const isServerComponent = const isServerComponent =
serverComponentRegex.test(absolutePagePath) serverComponentRegex.test(absolutePagePath)
const isInsideAppDir =
this.appDir && absolutePagePath.startsWith(this.appDir)
const staticInfo = await getPageStaticInfo({ const staticInfo = await getPageStaticInfo({
pageFilePath: absolutePagePath, pageFilePath: absolutePagePath,
...@@ -593,7 +595,7 @@ export default class HotReloader { ...@@ -593,7 +595,7 @@ export default class HotReloader {
}, },
onClient: () => { onClient: () => {
if (!isClientCompilation) return if (!isClientCompilation) return
if (isServerComponent) { if (isServerComponent || isInsideAppDir) {
entries[pageKey].status = BUILDING entries[pageKey].status = BUILDING
entrypoints[bundlePath] = finalizeEntrypoint({ entrypoints[bundlePath] = finalizeEntrypoint({
name: bundlePath, name: bundlePath,
......
...@@ -206,6 +206,8 @@ export function onDemandEntryHandler({ ...@@ -206,6 +206,8 @@ export function onDemandEntryHandler({
const isServerComponent = serverComponentRegex.test( const isServerComponent = serverComponentRegex.test(
pagePathData.absolutePagePath pagePathData.absolutePagePath
) )
const isInsideAppDir =
appDir && pagePathData.absolutePagePath.startsWith(appDir)
const pageKey = `${type}${pagePathData.page}` const pageKey = `${type}${pagePathData.page}`
...@@ -217,7 +219,7 @@ export function onDemandEntryHandler({ ...@@ -217,7 +219,7 @@ export function onDemandEntryHandler({
return return
} }
} else { } else {
if (type === 'client' && isServerComponent) { if (type === 'client' && (isServerComponent || isInsideAppDir)) {
// Skip adding the client entry here. // Skip adding the client entry here.
} else { } else {
entryAdded = true entryAdded = true
......
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