Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/build-test-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,39 @@ jobs:
node-version: ${{ matrix.node-version }}
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

test-pnpm:
runs-on: ubuntu-latest
name: "Tests [pnpm, isolated node_modules]"
steps:
- uses: actions/checkout@v7
- uses: pnpm/action-setup@v6
with:
version: 12
- uses: actions/setup-node@v6
with:
node-version: 'lts/*'
# yarn.lock is the source of truth - generate pnpm-lock.yaml from it
- run: pnpm import
- run: pnpm install --frozen-lockfile
- run: pnpm run typecheck
- run: pnpm run typecheck-ts
- run: pnpm run lint
- name: Run Jest Tests
run: |
max_attempts=3
attempt=1
until pnpm exec jest --ci --maxWorkers 4; do
if [ $attempt -ge $max_attempts ]; then
echo "Tests failed after $max_attempts attempts"
exit 1
fi
echo "Attempt $attempt failed, retrying..."
attempt=$((attempt + 1))
sleep 5
done

deploy:
# runs only on tag pushes
if: ${{ github.ref_type == 'tag' }}
Expand Down
Loading