Skip to content

Support pnpm via pnpm import from yarn.lock - #2110

Draft
robhogan wants to merge 2 commits into
pr2116from
pr2109
Draft

robhogan wants to merge 2 commits into
pr2116from
pr2109

Conversation

@robhogan

@robhogan robhogan commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

This is largely to have some mercy on my disk space - pnpm can use a shared store for node_modules.

Metro is developed with Yarn v1 and yarn.lock stays the source of truth, but this lets pnpm users work in the repo by generating a lockfile with pnpm import. It adds a pnpm-workspace.yaml (pnpm doesn't read workspaces from package.json), git-ignores the generated pnpm-lock.yaml and documents the two commands in the README.

Not covered yet: Flow never finishes crawling pnpm's node_modules - investigating that.

Changelog: Internal

Test plan:
On a fresh export of this stack, with each of pnpm 11.28.8 and 12.15.0, pnpm import then pnpm install --frozen-lockfile succeed, packages/metro/node_modules/metro-core is a symlink to ../../metro-core, and pnpm exec jest --no-watchman packages passes (155 suites, 2856 tests), as do build, lint, format-check, verify-api-snapshots, typecheck-ts and test-smoke.

Without allowBuilds, pnpm install exits 1 on both versions.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 26, 2026
@robhogan
robhogan changed the base branch from main to pr2116 October 26, 2026 16:13
@robhogan
robhogan added this pull request to stack #2119 October 26, 2026 16:14
Our root scripts use several packages that the root `package.json` doesn't declare. They work under Yarn only because hoisting happens to put them in the root `node_modules`:

 - `@babel/register` and `nullthrows`, used by `build` and the other scripts under `scripts/`
 - `flow-estree`, used by our lint rules
 - `@types/babel__core`, `@types/babel__traverse` and `@types/connect`, needed by `typecheck-ts`
 - `source-map@^0.6.1`. Our packages depend on 0.5, which ships no types, so `typecheck-ts` has been picking up the hoisted 0.6 typings instead. This keeps that behaviour explicit.

Each range matches what's already locked, so `yarn.lock` doesn't change. This is needed for any package manager that doesn't hoist, in particular pnpm.

Changelog: Internal

Test plan:
`yarn install --frozen-lockfile` passes with the unchanged `yarn.lock`.

Under pnpm 11.28.8 and 12.15.0, before this change `build`, `lint` and `typecheck-ts` fail on missing modules or declarations. After it, `build`, `lint`, `format-check`, `verify-api-snapshots`, `typecheck-ts` and `test-smoke` all pass.
Metro is developed with Yarn v1 and `yarn.lock` stays the source of truth, but this lets pnpm users work in the repo by generating a lockfile with `pnpm import`. It adds a `pnpm-workspace.yaml` (pnpm doesn't read `workspaces` from `package.json`), git-ignores the generated `pnpm-lock.yaml` and documents the two commands in the README.

The workspace file also sets two things. `linkWorkspacePackages` - without it, pnpm (since v9) resolves our exact-version internal dependencies like `"metro-core": "0.87.1"` from npm, which fails after a version bump that isn't published yet. `allowBuilds` declines `core-js-pure`'s postinstall (a funding banner) - otherwise pnpm 11+ fails the install with `ERR_PNPM_IGNORED_BUILDS`.

Not covered yet: Flow never finishes crawling pnpm's `node_modules` (`flow ls` was still going after 5 minutes, vs ~23k files with Yarn's layout). Ignoring the cross-linked workspace packages didn't help, so I've noted it in the README for now.

Changelog: Internal

Test plan:
On a fresh export of this stack, with each of pnpm 11.28.8 and 12.15.0, `pnpm import` then `pnpm install --frozen-lockfile` succeed, `packages/metro/node_modules/metro-core` is a symlink to `../../metro-core`, and `pnpm exec jest --no-watchman packages` passes (155 suites, 2856 tests), as do `build`, `lint`, `format-check`, `verify-api-snapshots`, `typecheck-ts` and `test-smoke`.

Without `allowBuilds`, `pnpm install` exits 1 on both versions.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant