Files
vercel__next.js/test/lib/pnpm-realpath-workaround.ts
Tobias Koppers f1285cec5f Use default pnpm package import method (#98703)
### What?

Use pnpm's default package import method in the two hoisted
isolated-test configurations added by #98425.

### Why?

`package-import-method` controls how regular package files are
materialized from pnpm's store: by reflink, hardlink, or copy. Those
choices do not affect `realpath`, so forcing copies is unrelated to the
Node.js symlink-resolution workaround and unnecessarily disables pnpm's
more efficient defaults.

### How?

Keep `node-linker=hoisted`, which is the setting responsible for
producing npm-style real package directories, while removing the
independent copy policy. The Node-version gate, local-tarball
validation, release-age policy, and fixture behavior remain unchanged.

### Verification

- Hoisted-only scratch install produced real package directories, no
package symlinks outside `.bin`, and a metadata-only `.pnpm`
- Production Turbopack: non-hoisted SWC helper and warm-restart task
stats passed (2/2)
- `pnpm build`
- `pnpm types`
- Prettier, ESLint, and `git diff --check`

Follow-up to #98425 and
https://github.com/vercel/next.js/pull/98425#discussion_r4020168942.

<!-- NEXT_JS_LLM -->


<!-- fleet 81cd457d-6956-4cf9-b6f6-9ebf9d95f285 -->

Co-authored-by: vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
2026-09-15 23:15:46 +00:00

21 lines
614 B
TypeScript

const PNPM_HOISTED_CONFIG = `# Work around the Node.js realpath bug fixed in 24.21.0 and 26.8.0.
# https://github.com/nodejs/node/pull/65113
node-linker=hoisted
`
function hasNodeRealpathFix(nodeVersion: string): boolean {
const [major, minor] = nodeVersion.split('.').map(Number)
return (
(major === 24 && minor >= 21) || major > 26 || (major === 26 && minor >= 8)
)
}
export function getPnpmRealpathWorkaround(
nodeVersion = process.versions.node
): Record<string, string> | undefined {
if (hasNodeRealpathFix(nodeVersion)) {
return undefined
}
return { '.npmrc': PNPM_HOISTED_CONFIG }
}