Ignore stray parent lockfiles when inferring workspace root#94597
Ignore stray parent lockfiles when inferring workspace root#94597scarab-systems wants to merge 1 commit into
Conversation
|
This is intentionally the highest one though. |
|
Thanks, that makes sense. I was optimizing for the stray-parent-lockfile failure in #92978, but I see the intended monorepo case here: I’ll revisit the patch with that invariant in mind instead of simply switching to “nearest wins.” I’ll either come back with a narrower change that distinguishes the stray-parent case from the nested-app-in-monorepo case, or update the PR if this needs a different direction. |
18f6257 to
68bb9a9
Compare
|
Following up on my note above: I reworked the PR around the narrower invariant you pointed to. The updated patch no longer makes this a blanket nearest-lockfile rule. It keeps higher workspace roots when they are explicit ( |
68bb9a9 to
ba0fcfb
Compare
What?
Updates workspace root inference so a parent lockfile is only promoted above the app lockfile when it has workspace authority. Explicit
pnpm-workspace.yamlroots still win, and parent package roots still win when theirpackage.jsondeclares workspaces.Plain parent lockfiles and parent package roots without workspaces are ignored, so accidental home-directory lockfiles do not become the inferred Turbopack/output tracing root.
Why?
A stray parent lockfile can make Next.js infer a root that is much broader than the app, which can send Turbopack module resolution and file watching through the wrong directory tree.
At the same time, higher monorepo roots can be intentional. This keeps that behavior instead of switching to a blanket "nearest lockfile wins" rule.
How?
pnpm-workspace.yamlas an explicit workspace root marker.package.json.multiple-lockfilese2e fixture so the warning case uses a valid parent workspace marker.Fixes #92978
Testing
pnpm testheadless packages/next/src/lib/find-root.test.tspnpm test-dev-turbo test/e2e/app-dir/multiple-lockfiles/multiple-lockfiles.test.tspnpm test-dev-turbo test/e2e/app-dir/multiple-lockfiles/multiple-lockfiles-with-turbo-root.test.tspnpm test-dev-turbo test/e2e/app-dir/multiple-lockfiles/multiple-lockfiles-with-output-file-tracing-root.test.tspnpm test-typespnpm lint-eslint packages/next/src/lib/find-root.ts packages/next/src/lib/find-root.test.ts test/e2e/app-dir/multiple-lockfiles/multiple-lockfiles.test.ts test/e2e/app-dir/multiple-lockfiles/multiple-lockfiles-with-turbo-root.test.ts test/e2e/app-dir/multiple-lockfiles/multiple-lockfiles-with-output-file-tracing-root.test.tspnpm exec prettier --check packages/next/src/lib/find-root.ts packages/next/src/lib/find-root.test.ts test/e2e/app-dir/multiple-lockfiles/multiple-lockfiles.test.ts test/e2e/app-dir/multiple-lockfiles/multiple-lockfiles-with-turbo-root.test.ts test/e2e/app-dir/multiple-lockfiles/multiple-lockfiles-with-output-file-tracing-root.test.tsgit diff HEAD^ HEAD --check