feat(package-managers): add bun support#3258
Conversation
There was a problem hiding this comment.
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
BunPackageManagerclass andBunRunnerto handle Bun-specific commands - Updated
PackageManagerFactoryto 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.
2bd7c21 to
b67325f
Compare
There was a problem hiding this comment.
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.
b67325f to
58d61e0
Compare
There was a problem hiding this comment.
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.
58d61e0 to
3d7948e
Compare
There was a problem hiding this comment.
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.
|
see #2223 |
|
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 My ExperienceI've been using Bun with NestJS in production on my own project (awaiden/haloidergisi) and have not encountered any issues with:
My {
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true
}
}And everything works flawlessly with Bun v1.2+. Why This PR is Safe NowThe concerns in #2223 were valid at that time (mid-2023), but:
I believe the concerns from #2223 are no longer applicable, and adding Bun to the supported package managers list is now safe and appropriate. |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
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:
BunPackageManagerandBunRunnerto handle Bun-specific commands.PackageManagerFactoryto automatically detect Bun by looking forbun.lockfiles.infocommand to display the Bun version when it's the active package manager.Does this PR introduce a breaking change?
Other information
Tested locally with
bun.lockdetection and version retrieval.