Skip to content

feat(package-managers): add bun support#3258

Open
awaiden wants to merge 1 commit intonestjs:masterfrom
awaiden:feat/add-bun-package-manager
Open

feat(package-managers): add bun support#3258
awaiden wants to merge 1 commit intonestjs:masterfrom
awaiden:feat/add-bun-package-manager

Conversation

@awaiden
Copy link

@awaiden awaiden commented Jan 29, 2026

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:

What is the current behavior?

The Nest CLI does not officially support Bun as a package manager. Users working in Bun-based environments have to manually specify another package manager or deal with fallback behaviors during project information display and package installation.

Issue Number: #3257

What is the new behavior?

This PR introduces official support for the Bun package manager:

  • Added BunPackageManager and BunRunner to handle Bun-specific commands.
  • Updated PackageManagerFactory to automatically detect Bun by looking for bun.lock files.
  • Enhanced the info command to display the Bun version when it's the active package manager.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

Tested locally with bun.lock detection and version retrieval.

Copilot AI review requested due to automatic review settings January 29, 2026 11:03
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for Bun as a package manager in the NestJS CLI, allowing users to work seamlessly with Bun-based projects without manual workarounds.

Changes:

  • Added BunPackageManager class and BunRunner to handle Bun-specific commands
  • Updated PackageManagerFactory to detect Bun projects via lockfile and create Bun instances
  • Enhanced package manager selection UI to include Bun as an option

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
lib/runners/bun.runner.ts New runner implementation for executing Bun commands
lib/runners/runner.ts Added BUN enum value for runner identification
lib/runners/runner.factory.ts Added factory case for creating BunRunner instances
lib/package-managers/bun.package-manager.ts New package manager implementation with Bun-specific CLI commands
lib/package-managers/package-manager.ts Added BUN enum value for package manager identification
lib/package-managers/package-manager.factory.ts Added Bun lockfile detection and BunPackageManager creation
lib/package-managers/index.ts Exported new BunPackageManager class
actions/new.action.ts Added Bun to package manager selection prompt
test/lib/package-managers/bun.package-manager.spec.ts Comprehensive test suite for BunPackageManager

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@awaiden awaiden force-pushed the feat/add-bun-package-manager branch 2 times, most recently from 2bd7c21 to b67325f Compare January 29, 2026 11:14
@awaiden awaiden requested a review from Copilot January 29, 2026 11:16
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@micalevisk
Copy link
Member

see #2223

@awaiden
Copy link
Author

awaiden commented Jan 29, 2026

Thanks for pointing out #2233 however, I'd like to clarify that the situation has significantly changed since then:

Since Bun v1.0.3 (September 2023), Bun has added full support for emitDecoratorMetadata and the Reflect Metadata API. This means NestJS now works perfectly with Bun as a runtime, not just as a package manager.

My Experience

I've been using Bun with NestJS in production on my own project (awaiden/haloidergisi) and have not encountered any issues with:

  • Dependency injection
  • Decorators (@Injectable(), @Controller(), etc.)
  • Metadata reflection
  • Any NestJS core features

My tsconfig.json includes:

{
  "compilerOptions": {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true
  }
}

And everything works flawlessly with Bun v1.2+.

Why This PR is Safe Now

The concerns in #2223 were valid at that time (mid-2023), but:

  1. Bun now supports emitDecoratorMetadata (since v1.0.3)
  2. Bun has a stable lockfile format (bun.lock)
  3. Bun is being used in production with NestJS by many developers
  4. The risk of confusion is minimal since Bun is now a legitimate runtime option for NestJS

I believe the concerns from #2223 are no longer applicable, and adding Bun to the supported package managers list is now safe and appropriate.

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