Skip to content

Comments

Add Bun lockfile support#1637

Draft
saramaebee wants to merge 4 commits intomasterfrom
bun
Draft

Add Bun lockfile support#1637
saramaebee wants to merge 4 commits intomasterfrom
bun

Conversation

@saramaebee
Copy link
Contributor

Summary

Add support for Bun package manager's lockfile (bun.lock) in the Node.js strategy.

What's Included

  • JSONC Parser: Parses bun.lock files (JSON with Comments format, default since Bun v1.2)
    • Handles trailing commas (common in real-world bun.lock files)
    • Strips // comments
  • Dependency Graph Builder: Constructs accurate dependency graphs
    • Direct vs transitive dependency detection
    • Dev vs production environment labeling
    • Workspace/monorepo support with package filtering
  • Strategy Integration: Full integration with Node.js discovery and analysis
    • Detection order: Yarn → NPM → Pnpm → Bun → fallback NPM

Format Support

Supports bun.lock (text/JSONC) which became the default in Bun v1.2 (December 2024). Binary bun.lockb is not supported as it's deprecated.

Testing

  • Comprehensive unit tests in test/Bun/BunLockSpec.hs
  • Tests cover parsing, graph building, workspace filtering, and trailing comma handling
  • All existing Node.js tests continue to pass

Commits

  1. Add Bun lockfile tactic implementation - Core parser and graph builder
  2. Add Bun lockfile tactic tests - Test suite with fixtures
  3. Integrate Bun tactic into Node.js strategy - Wire up discovery and dispatch

@saramaebee saramaebee requested a review from a team as a code owner February 4, 2026 20:49
@saramaebee saramaebee requested a review from GauravB159 February 4, 2026 20:49
saramaebee and others added 3 commits February 4, 2026 18:39
Add support for parsing Bun's bun.lock (JSONC format) lockfiles.
This includes:
- BunProjectType registration in Types.hs
- BunLock.hs with JSONC parser that handles trailing commas
- Dependency graph builder with workspace support
- Dev/production dependency labeling

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Comprehensive test suite for Bun lockfile parsing and graph building:
- Parsing tests for simple, workspace, and devdeps lockfiles
- JSONC trailing comma support tests
- Graph building tests for direct/transitive dependencies
- Environment labeling tests (dev vs production)
- Workspace package filtering tests

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Wire up Bun lockfile support in the Node.js strategy:
- Add Bun constructor to NodeProject ADT
- Add bun.lock detection in identifyProjectType
- Add Bun dispatch in getDeps
- Add BunProjectType to discovery filter

Detection order: Yarn -> NPM -> Pnpm -> Bun -> fallback NPM

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@GauravB159 GauravB159 requested a review from csasarak February 6, 2026 17:09
@saramaebee
Copy link
Contributor Author

I know I need to get the formatter passing and such, happy to draft this if yall want because I doubt I will have time within the next week

@csasarak
Copy link
Contributor

csasarak commented Feb 6, 2026

Yeah, if you could draft it that'd be good - I started to review. I'll put out what comments I have made already.

packageToDep :: BunPackage -> Bool -> Dependency
packageToDep pkg isDev =
let (name, version) = parseResolution pkg.resolution
env = if isDev then EnvDevelopment else EnvProduction
Copy link
Contributor

Choose a reason for hiding this comment

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

You can just pass EnvDevelopment or EnvProduction from the caller. The boolean is needlessly obscure IMO.


-- | Convert JSONC to valid JSON (copy from BunLock.hs for testing)
-- JSONC allows: // comments and trailing commas
stripJsoncComments :: Text -> Text
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't repeat this. This should be tested as part of the end-to-end parsing tests, right?

-- 2. Trailing commas before } or ]
--
-- This function strips both to produce valid JSON
stripJsoncComments :: Text -> Text
Copy link
Contributor

Choose a reason for hiding this comment

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

This really ought to be done with Megaparsec. I've put up a sample here.

The main thing is that it's kind of hard to follow these pieces. The Megaparsec impls like in the rest of our code base are more declarative. Also, megaparsec can handle the comment stuff for free.

@saramaebee saramaebee marked this pull request as draft February 7, 2026 17:04
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.

2 participants