Skip to content

Add support for Bun package manager in JavaScript hosting extensions#1243

Open
foxminchan wants to merge 3 commits intoCommunityToolkit:mainfrom
foxminchan:feature/support_bun
Open

Add support for Bun package manager in JavaScript hosting extensions#1243
foxminchan wants to merge 3 commits intoCommunityToolkit:mainfrom
foxminchan:feature/support_bun

Conversation

@foxminchan
Copy link
Copy Markdown
Contributor

@foxminchan foxminchan commented Mar 28, 2026

Closes #1242

  • Updated methods to include Bun as a package manager option.
  • Enhanced documentation to reflect Bun integration in README and MONOREPO files.

PR Checklist

  • Created a feature/dev branch in your fork (vs. submitting directly from a commit on main)
  • Based off latest main branch of toolkit
  • PR doesn't include merge commits (always rebase on top of our main, if needed)
  • New integration
    • Docs are written
    • Added description of major feature to project description for NuGet package (4000 total character limit, so don't push entire description over that)
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Contains NO breaking changes
  • Every new API (including internal ones) has full XML docs
  • Code follows all style conventions

Other information

- Updated methods to include Bun as a package manager option.
- Enhanced documentation to reflect Bun integration in README and MONOREPO files.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 28, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.sh | bash -s -- 1243

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.ps1) } 1243"

@foxminchan foxminchan marked this pull request as ready for review March 28, 2026 15:48
Copilot AI review requested due to automatic review settings March 28, 2026 15:48
Copy link
Copy Markdown
Contributor

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

Adds Bun support to the JavaScript hosting monorepo extensions so Nx/Turborepo workspaces can be configured to install and/or launch apps using Bun (via bun/bunx) alongside existing npm/yarn/pnpm support.

Changes:

  • Add bunbunx command mapping for Nx/Turborepo app execution when using WithPackageManagerLaunch.
  • Introduce WithBun(...) extension methods for Nx and Turborepo workspaces.
  • Expand existing test matrices and update docs to mention Bun.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/CommunityToolkit.Aspire.Hosting.JavaScript.Extensions.Tests/TurborepoResourceCreationTests.cs Extends Turborepo test coverage to include bun/bunx behavior.
tests/CommunityToolkit.Aspire.Hosting.JavaScript.Extensions.Tests/NxResourceCreationTests.cs Extends Nx test coverage to include bun/bunx behavior.
src/CommunityToolkit.Aspire.Hosting.JavaScript.Extensions/README.md Adds a Bun example and updates generated-command documentation.
src/CommunityToolkit.Aspire.Hosting.JavaScript.Extensions/MONOREPO.md Updates package manager documentation to include Bun and new API naming.
src/CommunityToolkit.Aspire.Hosting.JavaScript.Extensions/JavaScriptHostingExtensions.cs Implements Bun support via new WithBun overloads and command mapping.
Comments suppressed due to low confidence (1)

src/CommunityToolkit.Aspire.Hosting.JavaScript.Extensions/JavaScriptHostingExtensions.cs:143

  • In the Turborepo AddApp path, the args insertion falls back to "nx" when executionAnnotation.ScriptCommand is null. For Turborepo, the fallback should be "turbo" (matching WithPackageManagerLaunch(... runScriptCommand: "turbo")) to avoid generating an incorrect command if an annotation is present without a script command.
            })
              .WithArgs(context =>
              {
                  context.Args.Insert(0, executionAnnotation.ScriptCommand ?? "nx");
              });

// Bun example
var bunRepo = builder.AddTurborepoApp("bun-repo", workingDirectory: "../frontend")
.WithBun()
.WithPackageManagerLaunch("bun"); // Uses 'bun' command
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

In the Bun example, the comment says WithPackageManagerLaunch("bun") uses the bun command, but the implementation maps bun to bunx when generating the app command. Update the comment to reflect that the executable will be bunx (or adjust the example to pass "bunx" if that’s the intent).

Suggested change
.WithPackageManagerLaunch("bun"); // Uses 'bun' command
.WithPackageManagerLaunch("bun"); // Uses 'bunx' command

Copilot uses AI. Check for mistakes.
Comment on lines +49 to +53
Both Nx and Turborepo support yarn, pnpm, and bun package managers:

- `.WithYarnPackageInstaller()` - uses yarn
- `.WithPnpmPackageInstaller()` - uses pnpm
- `.WithYarn(install: true)` - uses yarn
- `.WithPnpm(install: true)` - uses pnpm
- `.WithBun(install: true)` - uses bun
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

This section was updated to recommend .WithYarn(install: true), .WithPnpm(install: true), etc., but the rest of MONOREPO.md still uses .WithYarnPackageInstaller() / .WithPnpmPackageInstaller() in the code samples, which don’t exist in the codebase. Please update the earlier examples and the “Package Installer” discussion to use the actual APIs (WithYarn(install: true), WithPnpm(install: true), WithBun(install: true), etc.) so the documentation is consistent and copy/paste-able.

Copilot uses AI. Check for mistakes.
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.

Support Bun installer for CommunityToolkit.Aspire.Hosting.JavaScript.Extensions

2 participants