Repository navigation
[pull] main from pnpm:main - #449
Merged
Merged
Conversation
pacquet never ran the root project's `pnpm:devPreinstall` script. The
hook exists so a workspace can prepare state that resolution or linking
consumes: vercel/next.js uses it to generate a placeholder `next` bin,
and without it every dependent's shim was linked against a file that no
step of the install ever created.
Run it once per install from the lockfile directory, for the root
project only, right after `pnpm:context` and before the lockfile is
touched — including before the frozen path's freshness check, matching
where pnpm runs it at the top of `mutateModules`' `_install`.
The gates were each checked against pnpm 11.17.0 on the same fixture:
- `--ignore-scripts` skips it, as it does every other project script.
- `--lockfile-only` and `--dry-run` skip it. pnpm reaches the same
outcome indirectly: `lockfileOnly` forces `ignoreScripts`, and
`--dry-run` sets `lockfileOnly`.
- A repeat "Already up to date" install skips it in both stacks — the
optimistic short-circuit returns before pnpm's `_install` and before
this call site.
- A rebuild skips it: `pnpm rebuild` never enters `mutateModules`.
- `ignore_manifest_check` skips it, covering both `pacquet fetch`
(pnpm's `ignorePackageManifest`) and the TypeScript CLI delegating a
frozen materialization, which already ran the hook itself before
handing the install over.
One duplicate remains: the TypeScript CLI's resolve-mode delegation
(`runPacquet.run({ resolve: true })`) drops both injected flags, so it
runs the hook and pacquet then runs it again. Every way to suppress it
was worse than the symptom — restating a ten-clause delegation
predicate in `_install`, where it would drift, or inventing a private
env-var marker — and the hook is idempotent by contract.
The env setup shared with the project-script path is split in two:
`pnpm:devPreinstall` takes the plain `extraEnv` + `nodeOptions`, without
the `.package-map.json` `NODE_OPTIONS` entry, because pnpm adds that one
only once it links and builds and the file does not exist yet when the
hook runs.
Closes #13313
Investigating #13326 showed its reproduction already matches pnpm 11 byte for byte, fixed by eab73b3 (#13374) filtering bundled names out of `extract_children`. Porting the upstream `bundledDependencies` install suite — which had no pacquet counterpart, and is why the original defect shipped — surfaced two gaps that fix did not cover. A manifest may declare `bundleDependencies: true` instead of a name list, which npm and pnpm both read as "every entry of `dependencies` ships inside this tarball". The lockfile writer only understood the list form, and `PackageMetadata::bundled_dependencies` was typed `Option<Vec<String>>`, so the boolean could neither be written nor read back — a `pnpm-lock.yaml` written by pnpm 11 for such a package failed to parse. Model the field as the `string[] | boolean` union pnpm records, behind one shared `BundledDependencies::from_manifest` that both the install and env-installer writers call. The field's presence is also what tells the installer a package carries a populated `node_modules` of its own whose bins belong in that package's `node_modules/.bin`. Bundled packages are not lockfile children, so neither linker reached them: the isolated path's per-slot walk iterates `snapshot.dependencies`, and the hoisted path iterates graph nodes — `has_bundled_dependencies` was computed and stored on every hoisted node but had no reader. Both paths now run the second bin pass upstream's `linkAllBins` and `building/during-install` run. No platform gate is added to the resolver. The issue asks for one, but pnpm 11 resolves the subtree of a platform-incompatible optional package too (`[email protected]` on Linux, `@img/sharp-darwin-arm64`'s libvips edge), and `skip_optional_dependency_that_does_not_support_the_current_os` already asserts pacquet matches that. Related to #13326
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )