Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import jsIcon from '@assets/icons/javascript.svg';
data-zoom-off
/>

The Aspire JavaScript/TypeScript hosting integration enables you to orchestrate JavaScript applications alongside your Aspire projects in the AppHost. This integration provides a unified approach to running JavaScript applications with support for multiple package managers (npm, yarn, pnpm), runtimes (Node.js), and build tools (Vite, and more).
The Aspire JavaScript/TypeScript hosting integration enables you to orchestrate JavaScript applications alongside your Aspire projects in the AppHost. This integration provides a unified approach to running JavaScript applications with support for multiple package managers (npm, yarn, pnpm, bun), runtimes (Node.js), and build tools (Vite, and more).

:::tip[Package rename]
In Aspire 13.0, the `Aspire.Hosting.NodeJs` package was renamed to `Aspire.Hosting.JavaScript` to better reflect its broader support for JavaScript applications.
Expand Down Expand Up @@ -106,7 +106,7 @@ var viteApp = builder.AddViteApp("vite-app", "./vite-app")

- **Development script**: Runs the "dev" script (typically `vite`) during local development
- **Build script**: Runs the "build" script (typically `vite build`) when publishing
- **Package manager**: Uses npm by default, but can be customized with `WithYarn()` or `WithPnpm()`
- **Package manager**: Uses npm by default, but can be customized with `WithYarn()`, `WithPnpm()`, or `WithBun()`

The method accepts the same parameters as `AddJavaScriptApp`:

Expand Down Expand Up @@ -183,6 +183,39 @@ var customApp = builder.AddJavaScriptApp("custom-app", "./custom-app")

When publishing, Aspire uses `pnpm install --frozen-lockfile` if `pnpm-lock.yaml` exists, otherwise it uses `pnpm install`.

### Use Bun

To use Bun as the package manager, call the `WithBun` extension method:

```csharp title="C# — AppHost.cs" "WithBun"
var builder = DistributedApplication.CreateBuilder(args);

var app = builder.AddViteApp("app", "./app")
.WithBun();

// Customize Bun with additional flags
var customApp = builder.AddViteApp("custom-app", "./custom-app")
.WithBun(installArgs: ["--frozen-lockfile"]);

// After adding all resources, run the app...
```

When publishing, Aspire uses `bun install --frozen-lockfile` if `bun.lock` or `bun.lockb` exists, otherwise it uses `bun install`.

Bun supports passing script arguments without the `--` separator, so commands like `bun run dev --port 3000` work without needing `bun run dev -- --port 3000`.

When publishing to a container, `WithBun()` automatically configures a Bun build image (`oven/bun:1`) since Bun is not available in the default Node.js base images. To use a specific Bun version, configure a custom build image:

```csharp title="C# — AppHost.cs"
var builder = DistributedApplication.CreateBuilder(args);

var app = builder.AddViteApp("app", "./app")
.WithBun()
.WithDockerfileBaseImage(buildImage: "oven/bun:1.1");

// After adding all resources, run the app...
```

## Customize scripts

You can customize which scripts run during development and build:
Expand Down