Skip to content

Conversation

@emilienbev
Copy link

@emilienbev emilienbev commented Jan 3, 2026

Description

This PR adds native bun support for Vite/JavaScript resources via a new WithBun() extension method, enabling bun install and bun run <script> flows similar to existing WithNpm(), WithYarn(), and WithPnpm() support.

Changes

  • Added WithBun() for JavaScriptAppResource-based resources.
  • Uses bun executable and run script command (bun run <script> ...).
  • Does not inject the -- command separator (bun forwards script flags without it).
  • Copies package.json + bun lockfile(s) for Docker layer caching (bun.lock / bun.lockb when present).
  • Sets bun cache mount for Dockerfile generation (/root/.bun/install/cache).
  • Ensures publish-mode Dockerfile generation can execute bun by overriding the build base image to oven/bun:1 when not already specified (assuming using latest isn't recommended here? Unsure.)

Fixes #13686

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

Copilot AI review requested due to automatic review settings January 3, 2026 00:30
@github-actions
Copy link
Contributor

github-actions bot commented Jan 3, 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/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13733

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 13733"

Copy link
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

This PR adds native Bun package manager support for JavaScript/Vite applications in Aspire, enabling developers to use bun install and bun run commands similar to existing npm, Yarn, and pnpm support.

Key Changes:

  • Introduces a new WithBun() extension method for JavaScript app resources that configures Bun as the package manager
  • Implements Bun-specific behavior: no command separator (--) when passing script flags, support for both bun.lock and bun.lockb files, and Docker base image override to oven/bun:1
  • Adds comprehensive test coverage for Bun installation arguments and command-line behavior

Reviewed changes

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

File Description
src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs Implements WithBun() extension method with Bun-specific configuration including lockfile handling, Docker image override, and install command setup
tests/Aspire.Hosting.JavaScript.Tests/PackageInstallationTests.cs Adds test verifying Bun uses --frozen-lockfile flag in publish mode
tests/Aspire.Hosting.JavaScript.Tests/AddViteAppWithPnpmTests.cs Adds test confirming Bun correctly omits command separator when passing script arguments

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jan 3, 2026
@emilienbev
Copy link
Author

@dotnet-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for bun as package manager

1 participant