Skip to content

Label Bun transitive devDependencies via graph hydration - #1737

Draft
zlav wants to merge 2 commits into
masterfrom
bun-hydrate-dev-deps
Draft

Label Bun transitive devDependencies via graph hydration#1737
zlav wants to merge 2 commits into
masterfrom
bun-hydrate-dev-deps

Conversation

@zlav

@zlav zlav commented Jul 28, 2026

Copy link
Copy Markdown
Member

Overview

The Bun lockfile strategy never ran graph hydration, so a dependency reachable only transitively through a devDependency was labeled production and survived dev-dependency filtering. This adopts the label-direct-then-hydrate pattern the other Node strategies use.

Problem: BunLock.buildGraph set each package's environment by name-membership in the set of directly-declared devDependencies. A transitive dep not itself listed in any workspace's devDependencies fell through to EnvProduction and was not filtered.

Fix:

  • Label only direct roots with their declared environment (dev → EnvDevelopment, prod/optional → EnvProduction); non-direct nodes carry no env label.
  • Run hydrateDepEnvs so environments propagate to transitive successors. A dep reachable only via dev deps becomes EnvDevelopment; a dep also reachable from a prod dep keeps EnvProduction.
  • No change to npm/git handling, workspaces, or graph shape.

Testing plan

  • New fixture test/Bun/testdata/transitive-dev/bun.lock + specs: a transitive dep of a dev dep is EnvDevelopment (regression), a transitive dep of a prod dep stays EnvProduction, and a dep reachable from both roots keeps production.
  • Updated the existing dependencies spec (semver via typescript is now dev, not prod).
  • make test-cabal ARGS="Bun" → 42 examples, 0 failures.

References

  • ANE-2836: Bun CLI strategy does not filter transitive devDependencies.
  • Sibling ANE-2852 (pnpm lockfile v9) fixed the same class of bug via the label+hydrate approach mirrored here.

Checklist

  • I added tests for this PR's change.
  • I updated Changelog.md under an ## Unreleased section.

zlav and others added 2 commits July 28, 2026 13:49
The Bun lockfile strategy assigned each package's environment by
name-membership in the set of directly-declared devDependencies and
never ran graph hydration. A dependency reachable only transitively
through a devDependency was labeled EnvProduction and survived
dev-dependency filtering.

Adopt the label-direct-then-hydrate pattern used by the other Node
strategies: label only direct roots with their declared environment,
then run hydrateDepEnvs so environments propagate down the edges. A dep
reachable only via dev deps becomes EnvDevelopment; a dep also reachable
from a prod dep keeps EnvProduction.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant