Bundler-Independent Node.js Dev Server

0.1.2 · active · verified Tue Apr 21

Serdev is a Node.js development server designed for complex project structures, particularly monorepos, where multiple components might have disparate build processes. It differentiates itself by being bundler-agnostic, allowing users to integrate various build tools like esbuild, Webpack, Rust's Cargo, or custom Node.js scripts. The server watches specified directories for changes, triggering rebuilds of components and serving the generated artifacts or proxying to embedded servers. It aims to streamline development workflows by consolidating diverse build and serving requirements into a single configuration. As of version 0.1.2, it is in a very early stage of development, implying potential instability and rapid evolution, without a specified regular release cadence. Its key strength lies in its flexibility to manage heterogeneous build ecosystems.

Common errors

Warnings

Install

Imports

Quickstart

This example configures `serdev` to manage and serve multiple distinct components within a monorepo, including custom build steps for TypeScript, Rust/WASM, and Node.js servers, alongside static file serving and API proxying, all with automatic rebuilds on file changes.

import * as serdev from "serdev";

serdev.listen({
  env: {
    RUST_BACKTRACE: "1"
  },
  headers: {
    "Cross-Origin-Opener-Policy": "same-origin",
    "Cross-Origin-Embedder-Policy": "require-corp"
  },
  components: {
    ui: {
      dir: "./ui",
      build: "esbuild --entry-points=src/index.ts --outdir=out --bundle --write",
      watch: ["src"]
    },
    website: {
      dir: "./website",
      build: "node scripts/build.js",
      watch: ["src"],
      deps: ["ui"]
    },
    app: {
      dir: "./app",
      build: "cargo build --target=wasm32-unknown-unknown",
      watch: ["src"]
    },
    api: {
      dir: "./api",
      build: "cargo build --features=dev",
      start: "target/debug/blob",
      port: 8001,
      watch: ["src"]
    },
    cdn: {
      dir: "./cdn",
      start: "node server.js",
      port: 8002
    }
  },
  routes: {
    "/favicon.ico": "./website/favicon.ico",
    "/app.js": ["app", "./app/out/index.js"],
    "/api/*": ["api"],
    "/assets/*rest": (x) => `./assets/${x.rest}`
  }
});

view raw JSON →