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 next-server tracing uses tracing root config #37888

Merged
merged 1 commit into from
Jun 21, 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/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,7 @@ export default async function build(
} catch (_) {}
}

const root = path.parse(dir).root
const root = config.experimental.outputFileTracingRoot || dir
const toTrace = [require.resolve('next/dist/server/next-server')]

// ensure we trace any dependencies needed for custom
Expand All @@ -1454,6 +1454,7 @@ export default async function build(
require.resolve(config.experimental.incrementalCacheHandlerPath)
)
}

const serverResult = await nodeFileTrace(toTrace, {
base: root,
processCwd: dir,
Expand Down
15 changes: 15 additions & 0 deletions test/integration/production/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,21 @@ describe('Production Usage', () => {
file.includes('next/dist/server/send-payload/index.js')
)
).toBe(true)
const repoRoot = join(__dirname, '../../../../')
expect(
serverTrace.files.some((file) => {
const fullPath = join(__dirname, '../.next', file)
if (!fullPath.startsWith(repoRoot)) {
console.error(`Found next-server trace file outside repo root`, {
repoRoot,
fullPath,
file,
})
return true
}
return false
})
).toBe(false)
expect(
serverTrace.files.some((file) =>
file.includes('next/dist/shared/lib/page-path/normalize-page-path.js')
Expand Down