rebuildjs
raw JSON → 0.71.1 verified Fri May 01 auth: no javascript
rebuildjs is a reactive esbuild-based build tool and development server for multi-page apps (MPAs), offering a simple, hackable alternative to Vite. It provides functions for both dev (with file watching, incremental builds, and a built-in HTTP server) and production builds. Currently at v0.71.1, it is actively developed with frequent releases. Key differentiators: full MPA focus, minimal configuration, and integration with `rmemo` for reactive state. Types are included. Requires `esbuild` as a peer dependency. The companion server framework `relysjs` (ElysiaJS-based) ties it together for app server usage.
Common errors
error Error: Cannot find module 'esbuild' ↓
cause Missing peer dependency esbuild.
fix
Install esbuild: npm install esbuild
error TypeError: (0 , rebuildjs.rebuildDev) is not a function ↓
cause Using `require` instead of `import` (CJS vs ESM).
fix
Switch to ESM import: import { rebuildDev } from 'rebuildjs'
error Build failed: unexpected version of esbuild ↓
cause Incompatible esbuild version installed.
fix
Update esbuild to ^0.27.3
Warnings
gotcha ESbuild ^0.27.3 required; older versions may cause build failures. ↓
fix Update esbuild to ^0.27.3.
breaking The `rebuildDev` function no longer returns the `watcher` object directly; access via returned object instead. ↓
fix Use destructured `{ server, close }` or check changelog for migration.
deprecated `rebuildWatch` is deprecated; use `rebuildDev` with `watch: true` instead. ↓
fix Replace `rebuildWatch` with `rebuildDev`.
gotcha CJS `require` will not work; package is ESM-only. ↓
fix Use `import` or run in an ESM project.
Install
npm install rebuildjs yarn add rebuildjs pnpm add rebuildjs Imports
- rebuildDev wrong
const rebuildDev = require('rebuildjs').rebuildDevcorrectimport { rebuildDev } from 'rebuildjs' - rebuild wrong
import rebuild from 'rebuildjs'correctimport { rebuild } from 'rebuildjs' - bundles
import { bundles } from 'rebuildjs' - default wrong
import { default as rebuildjs } from 'rebuildjs'correctimport rebuildjs from 'rebuildjs'
Quickstart
import { rebuildDev } from 'rebuildjs'
const PORT = process.env.PORT ?? 3000
const HOST = process.env.HOST ?? 'localhost'
const entry = ['src/index.ts']
async function start() {
const { server, close } = await rebuildDev({
entryPoints: entry,
outdir: 'dist',
port: PORT,
host: HOST,
onRequest: (req) => console.log(`${req.method} ${req.url}`)
})
console.log(`Dev server running at http://${HOST}:${PORT}`)
}
start()