Skip to content

CI: Test under pnpm's isolated node_modules - #2228

Merged
robhogan merged 1 commit into
mainfrom
pr2228
Nov 25, 2026
Merged

robhogan merged 1 commit into
mainfrom
pr2228

Conversation

@robhogan

@robhogan robhogan commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

#2116, #2257 etc fixed some missing dependencies, now we close the loop by ensuring we can't regress.

This adds a test-pnpm job to build-test-and-deploy. It generates pnpm-lock.yaml from yarn.lock with pnpm import, installs, and runs Flow, typecheck-ts, lint and Jest (with the same retries as the Yarn test job). It doesn't need to run on multiple platforms / versions so it's just Ubuntu and Node LTS.

Changelog: Internal

Test plan:
https://github.com/react/metro/actions/runs/44891928638/job/136809422962

@robhogan
robhogan added this pull request to stack #2119 November 16, 2026 15:45
@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 Nov 16, 2026
@robhogan
robhogan removed this pull request from stack #2119 November 21, 2026 09:05
@robhogan
robhogan added this pull request to stack #2268 November 21, 2026 09:05
@robhogan
robhogan removed this pull request from stack #2268 November 21, 2026 09:07
@robhogan
robhogan added this pull request to stack #2269 November 21, 2026 09:08
@robhogan
robhogan removed this pull request from stack #2269 November 21, 2026 09:23
@robhogan
robhogan added this pull request to stack #2271 November 21, 2026 09:23
@robhogan
robhogan force-pushed the pr2228 branch 2 times, most recently from 58b37fd to 29b7674 Compare November 21, 2026 09:56
@robhogan
robhogan marked this pull request as ready for review November 21, 2026 09:57
@robhogan
robhogan requested review from huntie and vzaidman November 21, 2026 09:58
@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Metro review: Looks good

Risk: low · Commit: 780fe45 · 6 commands run

This adds a CI job that builds pnpm-lock.yaml from yarn.lock with pnpm import, installs with pnpm 12's isolated node_modules, then runs Flow, typecheck-ts, lint and Jest. I ran the same steps with pnpm 12 in a scratch copy of the head. Import, frozen install, lint and typecheck-ts all pass, and Jest passes except for tests that need Watchman, which this sandbox blocks. The one remaining point is the nit from my last review: the comment above the job claims more than the job can catch.

Findings

Verified
  • ✅ pnpm@12 import (scratch copy of head) — Generated pnpm-lock.yaml from yarn.lock. The only warnings were about cyclic workspace dependencies and deprecated packages.
  • ✅ pnpm@12 install --frozen-lockfile (scratch copy of head, CI=1) — 924 packages installed. No unapproved build scripts blocked the install.
  • ✅ pnpm@12 run lint — 0 errors and 1 existing warning.
  • ✅ pnpm@12 run typecheck-ts — Shells out to yarn run build-ts-defs, which works because Yarn 1 is preinstalled on ubuntu-latest.
  • ⚠️ pnpm@12 run typecheck — Flow couldn't manage its server inside the package-manager sandbox (exit 4). This is an environment limit, not a problem with the PR.
  • ❌ pnpm@12 exec jest --ci --maxWorkers 4 --no-watchman — 179 of 181 suites and 3618 tests passed. The 13 failures were all in Watchman-backed watcher tests, which fail with fchmod ... Operation not permitted inside the sandbox. No failure came from module resolution.

Not run: I couldn't run Flow or the Watchman-backed Jest tests under pnpm here, because the package-manager sandbox blocks the Flow server and Watchman's state directory. The PR's linked CI run covers those steps on GitHub Actions. I also didn't run the workflow YAML itself, since there's no Actions runner locally. The job is Ubuntu-only, so Windows doesn't apply.

Automated review by Claude. Advisory only: it never approves or blocks, and a maintainer makes the call.

@robhogan
robhogan added this pull request to stack #2273 November 21, 2026 10:47
runs-on: ${{ matrix.runs-on }}

# Yarn hoists everything into the root node_modules, which can hide
# undeclared dependencies. pnpm's isolated node_modules catches them.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit · Root devDependencies stay resolvable from every workspace package, so this job can't catch those being undeclared

The comment says pnpm's isolated node_modules catches undeclared dependencies. That doesn't hold for anything in the root package.json devDependencies. pnpm links those into <root>/node_modules, and Node's resolution walks up from packages/<pkg>/ to that folder.

So if a workspace package starts using nullthrows, invariant, debug, @babel/core, @babel/types, source-map, flow-parser or similar without declaring it, every step of this job still passes.

The job still adds value. It catches undeclared packages that resolved only through Yarn's hoisting from another workspace's dependencies, including in tests, scripts and string-based require.resolve lookups. The import/no-extraneous-dependencies lint rule already covers static imports in packages/*/src.

Suggested fix: narrow the comment, e.g. "catches dependencies that only resolve via hoisting from other packages; root devDependencies remain visible to all workspaces".

Reproduced: In a pnpm 12 scratch install of the head (pnpm import then pnpm install --frozen-lockfile), packages/metro-cache/package.json doesn't declare nullthrows. Even so, require.resolve('nullthrows', {paths: ['packages/metro-cache/src']}) resolves to node_modules/.pnpm/nullthrows@1.1.1/... through the root link. · id dcbeedcb

#2116, #2257 etc fixed some missing dependencies, now we close the loop by ensuring we can't regress.

This adds a `test-pnpm` job to `build-test-and-deploy`. It generates `pnpm-lock.yaml` from `yarn.lock` with `pnpm import`, installs, and runs Flow, `typecheck-ts`, lint and Jest (with the same retries as the Yarn test job). It doesn't need to run on multiple platforms / versions so it's just Ubuntu and Node LTS.

Changelog: Internal

Test plan:
`actionlint` passes. Ran the job's steps locally against a fresh copy of this PR, with pnpm 12.21.0 (on Node 22.13 rather than 24) - all pass, including Jest (175 suites, 3475 tests).

CI on this PR runs the new job.
@robhogan
robhogan merged commit 1f9812e into main Nov 25, 2026
17 checks passed
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.

2 participants