Registry / web-framework / barely-a-dev-server

barely-a-dev-server

JSON →
library0.8.3jsnpmunverified

A thin, opinionated wrapper for esbuild that watches and serves TypeScript files as ESM. Current stable version: 0.8.3. Release cadence: irregular, with multiple minor releases in 2024. Key differentiators: minimal codebase (<200 lines), zero runtime dependencies beyond esbuild, automatic source maps, and integrated dev server that maps entry .ts files to .js. Unlike esbuild's own --servedir, this directly serves compiled output with live rebuilds. No CLI, no live reload, no non-TS transformations. Requires Node >=19 or Bun >=1.0.30.

npm install barely-a-dev-server
INSTALL
IMPORT
SIG · BARELY-A-DEV-SERVE
B
barely-a-dev-server
web-frameworkjavascriptv0.8.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

barelyServe
import { barelyServe } from 'barely-a-dev-server'
const barelyServe = require('barely-a-dev-server')
ESM-only package; CommonJS require() will fail. Named export, not default.
barelyServe
import { barelyServe } from 'barely-a-dev-server'
import barelyServe from 'barely-a-dev-server'
Default import is incorrect; use named import with braces.

Starts a dev server on port 3333 that watches and serves TypeScript files from the 'src' directory as ESM with source maps.

// script/build.js import { barelyServe } from 'barely-a-dev-server'; barelyServe({ entryRoot: 'src', dev: true, port: 3333, esbuildOptions: { target: 'esnext', }, });
Debug
Known issues
breakingv0.6.0 changed file globbing to rely on esbuild, which may break builds expecting custom pattern matching.
fix
If you relied on custom glob patterns, update your entry points to match esbuild's built-in resolution.
affects: >=0.6.0 <0.8.0
gotchaAll .ts files under entryRoot are treated as entry points, potentially generating many output files.
fix
Place library files outside entryRoot; only keep actual entry scripts inside.
affects: >=0.0.0
deprecatedv0.7.0 introduced bundleCSS option; prior versions do not support CSS bundling.
fix
Upgrade to >=0.7.0 and use bundleCSS option if CSS bundling is needed.
affects: <0.7.0
gotchaHTML files must reference .js output, not .ts source; the 'href' attribute is not processed by the server.
fix
In <script> tags, set src='./index.js' (not .ts). The href attribute is informational only.
affects: >=0.0.0
breakingv0.8.0 uses @cubing/dev-config/esbuild/es2022 under the hood, which may change build defaults (e.g., target).
fix
Check your code for ES2022 compatibility; override esbuildOptions.target if needed.
affects: >=0.8.0
breakingv0.6.1 removed a workaround for Bun; Bun >=1.0.30 is now required.
fix
Update Bun to >=1.0.30 or use Node >=19.
affects: >=0.6.1
gotchaNo CLI; you must import and call barelyServe manually or use node -e.
fix
Write a small script calling barelyServe() or run: node -e 'import("barely-a-dev-server").then(s => s.barelyServe({entryRoot: "src"}))'
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'barely-a-dev-server'
Trying to use CommonJS require() on an ESM-only package.
fix
Use import syntax: import { barelyServe } from 'barely-a-dev-server'
TypeError: barelyServe is not a function
Using default import instead of named import.
fix
Correct import: import { barelyServe } from 'barely-a-dev-server'
Failed to resolve entry point "src/index.ts"
Entry root contains .ts files that esbuild cannot resolve; possibly wrong path or missing file.
fix
Ensure entryRoot is relative to current working directory and contains .ts files.
Upgrade
Version history
0.8.3latest on npm
Audit
Dependencies
esbuildrequiredCore bundler and transpiler for TypeScript compilation, watch mode, and file serving.
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
barely-a-dev-server — npm install barely-a-dev-server · libregistry