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