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

Ensure app/layout.tsx can export preferredRegion #49031

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/next/src/build/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,12 @@ export async function getStaticInfoIncludingLayouts({
}
: pageStaticInfo

if (isInsideAppDir) {
if (isInsideAppDir && appDir) {
const layoutFiles = []
const potentialLayoutFiles = pageExtensions.map((ext) => 'layout.' + ext)
let dir = dirname(pageFilePath)
while (dir !== appDir) {
// Uses startsWith to not include directories further up.
while (dir.startsWith(appDir)) {
for (const potentialLayoutFile of potentialLayoutFiles) {
const layoutFile = join(dir, potentialLayoutFile)
if (!(await fileExists(layoutFile))) {
Expand Down
1 change: 1 addition & 0 deletions test/e2e/app-dir/app/app/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import '../styles/global.css'
import './style.css'

export const revalidate = 0
export const preferredRegion = 'sfo1'

async function getData() {
return {
Expand Down
5 changes: 5 additions & 0 deletions test/e2e/app-dir/app/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ createNextDescribe(
expect(middlewareManifest.functions['/test-page/page'].regions).toEqual(
['home']
)

// Inherits from the root layout.
expect(
middlewareManifest.functions['/slow-page-with-loading/page'].regions
).toEqual(['sfo1'])
})
}

Expand Down