Skip to content

feat: add bun module#1

Open
TomChv wants to merge 1 commit into
mainfrom
feat/add-bun-module
Open

feat: add bun module#1
TomChv wants to merge 1 commit into
mainfrom
feat/add-bun-module

Conversation

@TomChv

@TomChv TomChv commented Jul 17, 2026

Copy link
Copy Markdown
Member

A Dagger module for Bun, written in Dang,
modeled on dagger/deno. It models a Bun project
as a typed object graph and maps Bun's toolchain onto Dagger's first-class verbs
rather than wrapping the bun CLI.

Design rationale: design/bun-module.md.

Object graph

  • Bun — the pinned toolchain: version, base, install(ctr, musl), and
    lockfile-keyed discovery (projects, project --path).
  • BunProject — a single project; cascades source → container → installed and
    carries the verbs.

Verb mapping

The defining constraint: Bun ships no linter, formatter, or typechecker (it
transpiles TypeScript by stripping types), so this module implements only the
verbs Bun actually owns and delegates the rest.

  • Checks (@check): test (bun test), audit (bun audit),
    install-check (bun install --frozen-lockfile), plus workspace-wide
    test-all / audit-all / install-check-all.
  • Build functions: bundle → Directory!, compile → File! (cross-compile via
    --target); entrypoint defaults from package.json main.
  • Primitives: install(ctr, musl), base, container, installed; the
    install cache is a cacheVolume on ~/.bun/install/cache.
  • Zero @generate / @up, by design — Bun has no idempotent no-arg
    normalization and no guessable server entrypoint; dependency mutations
    (add/update) and dev servers are intentionally not modeled (see design doc).

Lint/format/typecheck are delegated to specialized modules (Biome/oxlint/ESLint,
Prettier/dprint, tsc), shown in the README's extension example.

Validation

.dagger/modules/e2e installs this module as a dependency and drives it against a
hello fixture plus in-memory workspaces for the failure paths.
dagger --x-release=v1.0.0-beta.7 check12 checks pass (clean-project,
compile, bundle, discovery fan-out, subdir-scope, subdir-enclosing, workspace, workspace-subdir,
failing-test, install-into-container, project-lookup).

Discovery keys on package.json + its workspaces field, so a monorepo's
members are enumerated individually
(a Bun workspace has one root bun.lock, so
lockfile-keying only found the root); each member installs at its workspace root so
workspace:* cross-deps resolve. It is also cwd-aware, a faithful implementation of
dagger/dagger#13688(parentConfigDir + descendantConfigDirs) — so from a
subdirectory the verbs act on the project you're in, shadowing farther-up
projects and skipping siblings. Verified against a real 4-member monorepo repro.

Verified against real images: bun is at /usr/local/bin/bun, glibc on
oven/bun:<v> and musl on -alpine (so install(musl:) copies the matching
build); targets need a C++ runtime (libstdc++), which debian:stable-slim has
and bare alpine does not.

Targets Dagger engine v1.0.0-beta.7; run with dagger --x-release=v1.0.0-beta.7
until that release is the default.

@TomChv TomChv changed the title docs: add design doc for the bun module docs: add bun module Jul 17, 2026
@TomChv TomChv changed the title docs: add bun module feat: add bun module Jul 17, 2026
@TomChv
TomChv marked this pull request as ready for review July 20, 2026 10:26
@TomChv
TomChv force-pushed the feat/add-bun-module branch 6 times, most recently from 50aa649 to 4e6aaf3 Compare July 20, 2026 16:27
A Dagger module for Bun, written in Dang, modeling the toolchain as an object
graph (Bun -> BunProject) instead of wrapping the CLI. Design: design/bun-module.md.

- Checks: test, audit, install-check (bun install --frozen-lockfile), plus the
  workspace-wide *-all variants.
- Build: bundle -> Directory, compile -> File (cross-compile via --target).
- Primitives: install(ctr, musl), base, container, installed; dependency cache as
  a cacheVolume. A pinned version drives the oven/bun image and the copied binary
  (glibc by default, musl for alpine targets).
- No @generate/@up, and no lint/format/typecheck: Bun ships none of those, so they
  are delegated to specialized modules (Biome/oxlint, Prettier/dprint, tsc).
- Discovery (dagger/dagger#13688) uses github.com/dagger/polyfill's findConfigDirs
  on package.json (cwd-aware). A monorepo's members are enumerated individually and
  each installs at its enclosing workspace root, keyed on the `workspaces` field
  (not bun.lock, so it works even without a committed lockfile); the root is
  dropped; from a subdirectory the verbs act on only the projects beneath it.
- e2e module under .dagger/modules/e2e (12 checks) drives the module against a
  fixture and in-memory workspaces; validated on engine v1.0.0-beta.7.

Signed-off-by: Tom Chauveau <tom@dagger.io>
@TomChv
TomChv force-pushed the feat/add-bun-module branch from 4e6aaf3 to 7faf2c1 Compare July 20, 2026 16:35
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.

1 participant