Skip to content

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

Open
robhogan wants to merge 1 commit into
pr2109from
pr2228
Open

robhogan wants to merge 1 commit into
pr2109from
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: 141ed09 · 4 commands run

This adds a test-pnpm CI job. It generates pnpm-lock.yaml from yarn.lock, installs with pnpm 12, and runs Flow, typecheck-ts, lint and Jest with the same retry loop as the Yarn test job. The job is correct and fits the pnpm workspace support in the PR below it. The one remaining point is the nit from last time: the comment overstates what isolated node_modules catches, because root devDependencies are still visible to every workspace package.

Findings

Verified
  • ✅ pnpm@12 import (scratch copy of head) — pnpm 12.21.0
  • ✅ pnpm@12 install --frozen-lockfile (scratch copy of head) — 924 packages; warns about cyclic workspace deps, as expected
  • ✅ node -e "require.resolve('nullthrows',{paths:['packages/metro-cache/src']})" in pnpm install — Resolves via the root devDependency link even though metro-cache doesn't declare it, which confirms the nit
  • ✅ jest --no-watchman --ci packages/metro-resolver packages/metro-cache (pnpm install) — 17 suites, 390 tests

Not run: I didn't run the full Jest suite, Flow, typecheck-ts or lint under the pnpm install. The PR links a passing CI run of this job, and the PR below it reports those passing under pnpm. No benchmark: this is a CI-only change. Nothing here is Windows-specific, since the job runs on Ubuntu only.

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

#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 removed this pull request from stack #2271 November 21, 2026 10:47
@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

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