Repository navigation
deps: migrate pnpm internals to v12 - #10508
Conversation
PR Summary by QodoMigrate Bit’s pnpm integration to pnpm v12 (N-API) with ESM shims
AI Description
Diagram
High-Level Assessment
Files changed (37)
|
Code Review by Qodo
1. strictSSL overridden by pnpm
|
|
Code review by qodo was updated up to the latest commit 4dc7b80 |
|
Code review by qodo was updated up to the latest commit ab13018 |
|
Code review by qodo was updated up to the latest commit 9068b8c |
|
Code review by qodo was updated up to the latest commit 3d3660f |
# Conflicts: # pnpm-lock.yaml
|
Code review by qodo was updated up to the latest commit aacaa7f |
|
Code review by qodo was updated up to the latest commit dda3274 |
|
Code review by qodo was updated up to the latest commit ba15aca |
|
Code review by qodo was updated up to the latest commit f0d4261 |
refToRelative returns null for link:-style refs, which importer entries can legitimately carry (the converter itself emits them); the non-null assertion produced neighbours with an invalid id.
|
Code review by qodo was updated up to the latest commit d393ee0 |
PkgMain constructs Packer at aspect init, so the module-scope @pnpm/napi import mapped the native engine into every process loading the pkg aspect; only pack needs it.
The last static value import of ./lynx from the package manager pulled the engine chain in at aspect init under eager compilation; only resolveRemoteVersion's path needs it.
lastIndexOf('@') treated a scoped alias's leading @ as the version
separator and required a version to exist, rejecting specs like
npm:uri-js-replace — which this repo's own overrides carry. The alias
now parses as an optionally scoped package name with an optional
version suffix.
|
Code review by qodo was updated up to the latest commit 6908795 |
@pnpm/[email protected] no longer depends on @pnpm/config.reader, so the config.env-replace chain is gone from the graph entirely and the mirror override for it is no longer needed.
|
Code review by qodo was updated up to the latest commit 0ab9444 |
…installs The bundle flow installs @teambit/bit into a fresh directory with its own hardcoded override list, so the workspace.jsonc overrides never apply there. bit.cloud's mirror caps @pnpm/config.nerf-dart below the ^2.0.1 the 11xx @pnpm packages need (and advertises an unservable lex-comparator 4.0.1), which would fail the bundle install once a bit version carrying those dependencies is published. Verified with pnpm 10.14.0 against the mirror: the bundle-style install fails without these overrides and succeeds with them.
strictSsl/ca/cert/key are optional in the engine's projection and set only when explicitly configured — presence is the explicit gate the numeric settings get from explicitSettings.
|
Code review by qodo was updated up to the latest commit ae65b53 |
…lls (#10551) ## Summary After the pnpm-v12/napi migration (#10508), every `bit install` wiped the `bit.depsRequiringBuild` block from `pnpm-lock.yaml`: ```diff bit: - depsRequiringBuild: - - '@apollo/[email protected]' - - '@parcel/[email protected]' - ... + depsRequiringBuild: [] ``` Root cause: the migration dropped the `returnListOfDepsRequiringBuild: true` install option (the napi engine did not implement it), so `installResult.depsRequiringBuild` only carried *blocked* builds. Bit allows dependency builds to run, so the list was always empty — and lynx wrote that empty list over the recorded block on every install. The fix: - Preserve the previously recorded list whenever the engine returns no list (`depsRequiringBuild` undefined): frozen-path repeat installs, and engines that predate the option. Verified against the currently pinned `@pnpm/napi` 12.0.0-beta.2 — a repeat install in this repo now leaves the block byte-identical. - Pass `returnListOfDepsRequiringBuild: true` again. Engine support was added in pnpm/pnpm#13532, so the next `@pnpm/napi` release reports the full list (every package whose files carry install scripts, regardless of the allow-build policy) on fresh resolves — the same semantics the pre-migration TypeScript engine had. --- Written by an agent (Claude Code, claude-fable-5). --------- Co-authored-by: Claude Fable 5 <[email protected]>
## Summary `bit install` fails on any dependency that shells out to `node-gyp`: ``` .../node_modules/bufferutil install$ node-gyp-build │ Error: spawn node-gyp ENOENT [email protected] install: `node-gyp-build` exited with exit status: 1 ``` The pnpm engine spawns dependency lifecycle scripts with the PATH of the bit process plus the relevant `node_modules/.bin` dirs, and ships no `node-gyp` of its own (`pacquet`'s `node_gyp_bin` / `node_gyp_path` lifecycle options exist, but every caller passes `None`). Before #10508 Bit inherited a `node-gyp` wrapper from `@pnpm/npm-lifecycle`, which depends on node-gyp and prepends its wrapper dir to PATH for every script it spawns — the old lockfile had `[email protected]` through it, the new one has none. So anything that falls back to `node-gyp rebuild` — `node-gyp-build` with no matching prebuild, `node-pre-gyp`, or a plain `"install": "node-gyp rebuild"` — now dies with `spawn node-gyp ENOENT`. It shows up on platforms a package has no prebuild for: `[email protected]` ships no darwin-arm64 prebuild, so every Apple Silicon install of it fails. ## Changes - **`node-gyp-bin.ts`** (new) — writes an npm-style `node-gyp` wrapper into `<bit-cache>/node-gyp-bin/<key>` and appends it to `process.env.PATH`. Appended rather than prepended, so a node-gyp the user installed themselves still wins. The directory is keyed by a hash of the `node` and `node-gyp.js` paths baked into the wrapper, so a Bit or Node upgrade gets a fresh directory instead of rewriting a script a concurrent install may be executing; wrappers are written temp-file-then-rename. `process.env` is the only lever available here — `InstallOptions` exposes no `extraBinPaths` (only `PackOptions` does). - **`lynx.ts`** — call it once in `install()`, which covers both `nodeApi.install` and the returned `rebuild`. - **`workspace.jsonc`** — `node-gyp: 11.5.0` in the root policy and in a new variant for `scopes/dependencies/pnpm`. The variant entry is required: nothing imports node-gyp, so dependency detection would never add it to `@teambit/pnpm`'s package.json. 11.x rather than 13.x because node-gyp 13 requires Node `^22.22.2` and bvm ships 22.22.0. The complete fix belongs upstream — `pacquet` already has the `node_gyp_bin` plumbing, it just has nothing to point it at — but Bit needs to ship a `node-gyp` either way. ## Test plan - [x] `npm run lint` - [x] `bit test scopes/dependencies/pnpm/node-gyp-bin.spec.ts` — 3/3 passing - [x] Scratch workspace with `[email protected]` (`"install": "node-gyp rebuild"`): released `bit` → `sh: line 1: node-gyp: command not found`, exit 127. Local build → node-gyp runs (`node-gyp -v v11.5.0`, invoked as `<node> <…>/node-gyp.js`); the compile then fails on its own merits, since that 2016 nan addon does not build against Node 22. - [x] Same workspace with `[email protected]` and `npm_config_build_from_source=true` to force the gyp path: `bit install` completes green and produces a real `build/Release/bufferutil.node`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
bit-lite-deps drove installs through @pnpm/core and friends. Those packages are frozen on the v10 line and have no v11 or v12 release: pnpm moved its install engine to Rust and now exposes it through @pnpm/napi instead. Latest Bit made the same move (teambit/bit#10508, 2026-07-31), so this follows a proven path rather than inventing one. Replace the programmatic v10 API with @pnpm/napi: - `nodeApi.install` receives a typed InstallOptions built from the same settings the old InstallOptions carried. - Progress comes from the engine's log callback. The engine emits wire-compatible pnpm log records, so the parsing in progress.ts is unchanged and only the transport is new. - The addon is loaded through createRequire: it is CommonJS, and Node's named-export detection only finds `install` on it. - Local packages from an enclosing repository become `link:` overrides rather than projects. The engine has no equivalent of the old allProjects / mutations split, so a project is always an install target; overriding by name links without installing. Paths are relative so the generated lockfile stays portable. - A `pnpm-workspace.yaml` is written to the install root. InstallOptions.dir is not authoritative: without the marker the engine walks up, adopts an enclosing pnpm workspace as its lockfile root, and prunes that repository's node_modules. Behaviour differences worth noting: `excludeLinksFromLockfile` is dropped because setting it stops the engine from linking workspace packages at all, and `resolutionMode`, `preferWorkspacePackages`, `strictPeerDependencies` and `modulesCacheMaxAge` have no counterpart in the binding. Co-Authored-By: Claude Opus 5 <[email protected]>
bit-lite-deps drove installs through @pnpm/core and friends. Those packages are frozen on the v10 line and have no v11 or v12 release: pnpm moved its install engine to Rust and now exposes it through @pnpm/napi instead. Latest Bit made the same move (teambit/bit#10508, 2026-07-31), so this follows a proven path rather than inventing one. Replace the programmatic v10 API with @pnpm/napi: - `nodeApi.install` receives a typed InstallOptions built from the same settings the old InstallOptions carried. - Progress comes from the engine's log callback. The engine emits wire-compatible pnpm log records, so the parsing in progress.ts is unchanged and only the transport is new. - The addon is loaded through createRequire: it is CommonJS, and Node's named-export detection only finds `install` on it. - Local packages from an enclosing repository become `link:` overrides rather than projects. The engine has no equivalent of the old allProjects / mutations split, so a project is always an install target; overriding by name links without installing. Paths are relative so the generated lockfile stays portable. - A `pnpm-workspace.yaml` is written to the install root. InstallOptions.dir is not authoritative: without the marker the engine walks up, adopts an enclosing pnpm workspace as its lockfile root, and prunes that repository's node_modules. Behaviour differences worth noting: `excludeLinksFromLockfile` is dropped because setting it stops the engine from linking workspace packages at all, and `resolutionMode`, `preferWorkspacePackages`, `strictPeerDependencies` and `modulesCacheMaxAge` have no counterpart in the binding. Co-Authored-By: Claude Opus 5 <[email protected]>
bit-lite-deps drove installs through @pnpm/core and friends. Those packages are frozen on the v10 line and have no v11 or v12 release: pnpm moved its install engine to Rust and now exposes it through @pnpm/napi instead. Latest Bit made the same move (teambit/bit#10508, 2026-07-31), so this follows a proven path rather than inventing one. Replace the programmatic v10 API with @pnpm/napi: - `nodeApi.install` receives a typed InstallOptions built from the same settings the old InstallOptions carried. - Progress comes from the engine's log callback. The engine emits wire-compatible pnpm log records, so the parsing in progress.ts is unchanged and only the transport is new. - The addon is loaded through createRequire: it is CommonJS, and Node's named-export detection only finds `install` on it. - Local packages from an enclosing repository become `link:` overrides rather than projects. The engine has no equivalent of the old allProjects / mutations split, so a project is always an install target; overriding by name links without installing. Paths are relative so the generated lockfile stays portable. - A `pnpm-workspace.yaml` is written to the install root. InstallOptions.dir is not authoritative: without the marker the engine walks up, adopts an enclosing pnpm workspace as its lockfile root, and prunes that repository's node_modules. Behaviour differences worth noting: `excludeLinksFromLockfile` is dropped because setting it stops the engine from linking workspace packages at all, and `resolutionMode`, `preferWorkspacePackages`, `strictPeerDependencies` and `modulesCacheMaxAge` have no counterpart in the binding. Co-Authored-By: Claude Opus 5 <[email protected]>
Summary
@pnpm/[email protected]and the pnpm v12 package split, including the new@pnpm/<domain>.<leaf>helper packages.@pnpm/config.readerand typed config fields.ERR_PNPM_SPEC_NOT_SUPPORTED_BY_ANY_RESOLVERpath.pull/<id>/merge, bounded GitHub API lookup, and regression coverage for the branch-ref matcher.@pnpm/napi.*native binaries for linux/macos/windows bundles, and rebuild second-arch bundles from a clean install directory.Test plan
bit compile teambit.dependencies/pnpm teambit.dependencies/dependency-resolver teambit.git/cibit test scopes/dependencies/pnpm/lynx.spec.ts scopes/dependencies/pnpm/lockfile-deps-graph-converter.spec.ts scopes/dependencies/dependency-resolver/dependency-resolver.main.runtime.spec.ts— 34/34 passedbit test scopes/git/ci/pull-request-ref.spec.ts— 2/2 passednpm run mocha-circleci -- e2e/harmony/deps-graph.e2e.ts --grep "two components with different peer dependencies( should| importing)"— 7 passingnpm run mocha-circleci -- e2e/harmony/dependencies/never-built-dependencies.e2e.ts --grep "using pnpm"— 1 passingnpm run mocha-circleci -- e2e/harmony/ci-commands.e2e.ts --grep "bit ci pr workflow"— 6 passingnpm run mocha-circleci -- e2e/harmony/root-components.e2e.ts --grep "pnpm hoisted linker"— 12 passing, 2 pending[email protected]hoisted/copy install of@pnpm/[email protected] --os=linux --cpu=arm64verified the targetpnpm-napi.nodebinary.circleci/config.ymlparsed with the repoyamlpackagenpm run lint-circlebit test scopes/dependencies/pnpm/lynx.spec.ts scopes/dependencies/dependency-resolver/dependency-resolver.main.runtime.spec.ts— 13/13 passed after lint-only fixesReplaces #10293.