Skip to content
Closed
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
6 changes: 3 additions & 3 deletions packages/next/src/server/app-render/app-render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4201,9 +4201,9 @@ const getGlobalErrorStyles = async (
}
if (ctx.renderOpts.dev) {
const dir =
process.env.NEXT_RUNTIME === 'edge'
? process.env.__NEXT_EDGE_PROJECT_DIR!
: ctx.renderOpts.dir || ''
(process.env.NEXT_RUNTIME === 'edge'
? process.env.__NEXT_EDGE_PROJECT_DIR
: ctx.renderOpts.dir) || ''

const globalErrorModulePath = normalizeConventionFilePath(
dir,
Expand Down
12 changes: 6 additions & 6 deletions packages/next/src/server/app-render/create-component-tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,9 @@ async function createComponentTreeInternal(
process.env.NODE_ENV === 'development' &&
ctx.renderOpts.devtoolSegmentExplorer
const dir =
process.env.NEXT_RUNTIME === 'edge'
? process.env.__NEXT_EDGE_PROJECT_DIR!
: ctx.renderOpts.dir || ''
(process.env.NEXT_RUNTIME === 'edge'
? process.env.__NEXT_EDGE_PROJECT_DIR
: ctx.renderOpts.dir) || ''

// Use the same condition to render metadataOutlet as metadata
const metadataOutlet = StreamingMetadataOutlet ? (
Expand Down Expand Up @@ -1139,9 +1139,9 @@ async function createBoundaryConventionElement({
process.env.NODE_ENV === 'development' &&
ctx.renderOpts.devtoolSegmentExplorer
const dir =
process.env.NEXT_RUNTIME === 'edge'
? process.env.__NEXT_EDGE_PROJECT_DIR!
: ctx.renderOpts.dir || ''
(process.env.NEXT_RUNTIME === 'edge'
? process.env.__NEXT_EDGE_PROJECT_DIR
: ctx.renderOpts.dir) || ''
const { SegmentViewNode } = ctx.componentMod
const element = Component ? (
<>
Expand Down
8 changes: 7 additions & 1 deletion packages/next/src/server/app-render/segment-explorer-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@ export function normalizeConventionFilePath(
projectDir: string,
conventionPath: string | undefined
) {
// Turbopack project path is formed as: "<project root>/<cwd>".
// When project root is not the working directory, we can extract the relative project root path.
// This is mostly used for running Next.js inside a monorepo.
const cwd = process.env.NEXT_RUNTIME === 'edge' ? '' : process.cwd()
const relativeProjectRoot = projectDir.replace(cwd, '')

let relativePath = (conventionPath || '')
// remove turbopack [project] prefix
.replace(/^\[project\][\\/]/, '')
.replace(/^\[project\]/, '')
// remove turbopack relative project path, everything after [project] and before the working directory.
.replace(relativeProjectRoot, '')
// remove the project root from the path
.replace(projectDir, '')
// remove cwd prefix
Expand Down
Loading