Add support for Bun package manager in JavaScript hosting extensions#1243
Add support for Bun package manager in JavaScript hosting extensions#1243foxminchan wants to merge 3 commits intoCommunityToolkit:mainfrom
Conversation
- Updated methods to include Bun as a package manager option. - Enhanced documentation to reflect Bun integration in README and MONOREPO files.
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.sh | bash -s -- 1243Or
iex "& { $(irm https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.ps1) } 1243" |
There was a problem hiding this comment.
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
bun→bunxcommand mapping for Nx/Turborepo app execution when usingWithPackageManagerLaunch. - 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
AddApppath, the args insertion falls back to"nx"whenexecutionAnnotation.ScriptCommandis null. For Turborepo, the fallback should be"turbo"(matchingWithPackageManagerLaunch(... 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 |
There was a problem hiding this comment.
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).
| .WithPackageManagerLaunch("bun"); // Uses 'bun' command | |
| .WithPackageManagerLaunch("bun"); // Uses 'bunx' command |
| 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 |
There was a problem hiding this comment.
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.
Closes #1242
PR Checklist
Other information