ADR 0017 — Bun + Nitro without Vite: @fellowframework/build
Status: accepted. Date: 2026-12-03. Supersedes: the front-end part of ADR 0001. Principles: no Vite and no Node.js process, in development or production.
Context
ADR 0001 built the application with Vite (@vitejs/plugin-vue + nitro/vite). Fellow forbids Vite and any
Node.js process. Bun and Nitro v3 cover everything Vite did for Fellow: the Vue SFC
pipeline, CSS/Sass, the client build, server rendering, state-preserving HMR and the dev server.
Decision
A new package, @fellowframework/build, owns the toolchain. Everything runs inside the fellow Bun process.
- Server: Nitro v3 driven in-process through
nitro/builder(createNitro,prepare,build,createDevServer,copyPublicAssets,prerender), Bun builder,bunpreset by default. No Nitro CLI, so no#!/usr/bin/env nodeshebang is ever executed. - Client (production): one
Bun.buildfrom the entry named inindex.html, code splitting, hashed names under/_fellow/, Vue SFCs compiled with@vue/compiler-sfcin a Bun plugin, Sass through the optionalsasspackage, assets as files. The output goes topublic/_fellow/and Nitro serves it as public assets. - Page shell:
index.htmlis the template. The client build writes.fellow/shell.htmlwith the hashed CSS and JS; Nitro’srenderer.templatepoints to it, and the core reads it through the virtual module#fellow/shellto inject page objects. - Pages map:
fellowgeneratesexport const pagesinsrc/fellow.gen.ts(one lazy import per page component) instead ofimport.meta.glob, which is a Vite feature. - Dev server: Nitro’s dev server plus a Fellow module server behind
devProxyat/_fellow/dev/**:- app modules served unbundled (
/_fellow/dev/@fs/...), TypeScript stripped byBun.Transpiler; - bare imports pre-bundled in ONE
Bun.buildwith splitting (/_fellow/dev/@deps/<id>.js?v=N), so a package shared by two dependencies is a single instance; a dependency first seen at request time triggers a rebuild; - HMR over Server-Sent Events: template-only
.vueedits rerender through__VUE_HMR_RUNTIME__(state kept), script edits re-create the component, CSS is swapped in place, any other edit reloads the page after Nitro has rebuilt (no hydration mismatch), and adding or removing a route file regeneratesfellow.gen.tsand restarts Nitro.
- app modules served unbundled (
Evidence
packages/build/tests/build.test.ts: SFC compilation (dev/HMR/production, template-only), shell rendering, dependency pre-bundling with a shared chunk and a clear error for a missing package.packages/build/tests/records.e2e.test.tsonexamples/records, real Chromium:fellow build→bun .output/server/index.mjs; the login page hydrates fromBun.buildchunks, unknown URLs render the client 404 page, no page errors, novitein the server bundle;fellow dev: a template edit keeps the typed input value and a window marker; a CSS edit applies without a reload; a script edit re-creates the component without a reload; a server edit reloads the page; a new route file is served without a manual restart, and removing it takes the route away;- negative control:
fellow dev --no-hmrloses the input value and the marker on the same template edit.
packages/cli/tests/templates.test.ts: every template scaffolds without Vite, passesfellow checkwith real type checking, and thewebtemplate builds withfellow build.- The same tests were run with
node,npm,npxandvitereplaced by traps and every process traced: 9/9, no Node.js or Vite process started.
Known upstream issues and workarounds
- Nitro #4999 (released RC): in dev, Nitro’s Bun builder targets
nodefor thenitro-devpreset, sobunimports becomenode:bunand the worker fails. Workaround:bunConfig: { target: 'bun' }in dev. Fixed upstream by #5043 (unreleased); remove the override when the next RC ships it. - Nitro renderer auto-detection: Nitro uses
index.htmlas the renderer template when present. Fellow setsrenderer.templateto the built shell, otherwise unknown URLs would serve the raw template. - Nitro #5184: empty prerender output; Fellow does not rely on prerendering for server apps.
Bun versions
- Tested on Bun 1.4.4. Bun 1.4.5 is a security-only release with no API change; the session could not install
it (installer blocked by the environment), so the 1.4.5 run is still owed.
engines.bunis>=1.4.4. - Bun 1.5 readiness (breaking changes tracked in oven-sh/bun#49571), enforced in this package:
- every
Bun.buildpassesjsx: { development }anddefine['process.env.NODE_ENV']explicitly, so the proposed default changes do not alter output; - plugin
onResolvehooks always return a result or nothing on purpose (1.5: nothing means “not handled”); - each path lives in one namespace (1.5: the same path in two namespaces is two modules);
- no code writes to namespace objects (1.5 flips
deprecatedNamespaceObjectSetters); - Bun.SQL: no
sql.array()without explicit types and nounsafe(text, {})(core passes arrays only); - the 1.5 CSS rewrite (#47025) fixes the
@container style(--x)parse error that Bun 1.4 hits in some component libraries’ CSS (Vuetify); until 1.5 is the floor, link such stylesheets as files.
- every
- A CI job on Bun canary should run
bun test packagesbefore 1.5 is released.
Consequences
vite,@vitejs/plugin-vueandvite.config.tsare gone from the templates and the example;fellow doctorwarns when a Vite config is left in a project.- Fellow owns more toolchain code (about 700 lines in
@fellowframework/build), covered by the tests above. - There is no public Bun dev-bundler/HMR API yet; if one ships, the module server can be replaced by it.