mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-12 10:11:42 -04:00
pnpm 10 transitively emitted an npm-CLI-shaped per-package JSON object on stdout for `pnpm publish --json` because the publish command shelled out to npm. pnpm 11 (#10591) reimplemented publish natively and the new handler returned undefined, so `--json` now produces 0 bytes on stdout on success — silently breaking downstream tooling that grepped that contract. The most impactful regression is `nx release publish`, which parses stdout JSON to confirm success; under `--nx-bail=true` it aborts the rest of a release run when JSON is missing (see nrwl/nx#35575). This restores the contract for both single-package and recursive publish, and aligns `--report-summary` to use the same per-package shape: - `pnpm publish --json` → single object `{ id, name, version, size, unpackedSize, shasum, integrity, filename, files, entryCount, bundled }`, mirroring `npm publish --json`. - `pnpm publish -r --json` → array of those objects, mirroring `pnpm pack --json`'s shape choice for single vs multi. - `pnpm publish -r --report-summary` → existing `pnpm-publish-summary.json` envelope `{ publishedPackages: [...] }` is preserved, but each entry is upgraded to the same per-package shape (additive — `name` and `version` are still present). Implementation: - `pack.api()` computes `unpackedSize` while it still has the filesMap. - `publishPackedPkg` returns a `PublishSummary` (SHA-1 `shasum` + SHA-512 `integrity` via `node:crypto`, no new deps) instead of `void`. - `bundled` normalizes `bundledDependencies` / `bundleDependencies` per npm's semantics (including `true` → all dep names). - `recursivePublish` collects per-package `PublishSummary` objects and returns them; the existing manifest-pick fallback is kept for paths that don't produce a summary. - `publish.handler` returns `{ output, exitCode }` with the serialized summary (object or array) when `opts.json` is set; main.ts already writes `output` to stdout. Refs #11476 Refs nrwl/nx#35575 Amp-Thread-ID: https://ampcode.com/threads/T-019df90f-8f75-763f-b528-4602e870a972 Co-authored-by: Charlie Croom <charlie+amp@noreply.com> Co-authored-by: Amp <amp@ampcode.com>