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

Fix client entry unexpectedly created in app dir #37561

Merged
merged 2 commits into from
Jun 9, 2022
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
3 changes: 2 additions & 1 deletion packages/next/build/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion packages/next/server/dev/hot-reloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion packages/next/server/dev/on-demand-entry-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`

Expand All @@ -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
Expand Down