{"id":25274,"library":"esbuild-dev-router","title":"esbuild-dev-router","description":"Express middleware for development with esbuild. Bundles TypeScript/JavaScript source files in memory, serves them directly, and automatically reloads the browser on file changes via Server-Sent Events. Current stable version is 0.8.0. Peer dependency on esbuild >0.17. Key differentiators: zero-config live reload injection, no disk writes, mounts as Express Router, merges loader and plugin configs so you can extend defaults. Best for teams that already use Express and esbuild and want a lightweight dev server without Webpack or Vite.","status":"active","version":"0.8.0","language":"javascript","source_language":"en","source_url":"https://github.com/zoisgr/esbuild-dev-router","tags":["javascript","esbuild","dev-server","express","middleware","live-reload","typescript","development"],"install":[{"cmd":"npm install esbuild-dev-router","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-dev-router","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-dev-router","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; >=0.17 is required for the esbuild API used internally","package":"esbuild","optional":true}],"imports":[{"note":"ESM-only; in TypeScript, you can also use the named export 'devRouter'","wrong":"const devRouter = require('esbuild-dev-router')","symbol":"default (devRouter)","correct":"import devRouter from 'esbuild-dev-router'"},{"note":"Both default and named exports point to the same function. The named export may be easier in some bundler setups.","wrong":"import devRouter from 'esbuild-dev-router'","symbol":"devRouter (named)","correct":"import { devRouter } from 'esbuild-dev-router'"},{"note":"Re-exports esbuild's BuildOptions type for convenience. Use it to type your config object.","wrong":null,"symbol":"BuildOptions","correct":"import { BuildOptions } from 'esbuild-dev-router'"}],"quickstart":{"code":"import express from 'express';\nimport devRouter from 'esbuild-dev-router';\nimport { resolve } from 'path';\n\nconst app = express();\nconst port = process.env.PORT ?? 5000;\n\napp.use(devRouter({\n    entryPoints: [resolve(process.cwd(), 'src/index.ts')],\n    outdir: resolve(process.cwd(), 'dist'),  // used for path resolution only\n}));\n\napp.use(express.static(resolve(process.cwd(), 'public')));\n\napp.listen(port, () => {\n    console.log(`Dev server running on http://localhost:${port}`);\n});","lang":"typescript","description":"Sets up a basic Express dev server with esbuild-dev-router, bundling src/index.ts into memory and serving static files from public/."},"warnings":[{"fix":"Mount at app root: app.use(devRouter({...})). Do NOT mount under a subpath like '/assets'.","message":"Must be mounted at root path — the SSE reloader endpoint is hardcoded to '/reloader'.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Remove any 'write' option from the config; it does nothing.","message":"The 'write' option is always forced to false and cannot be overridden.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"If you provide 'loader', your entries are added alongside .png and .jpg defaults. For other options, your value completely overrides the default.","message":"Defaults merge for 'loader', 'plugins', and 'inject' but other options replace defaults.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Upgrade Node.js to version 18 or later.","message":"Node.js 18+ required. Older Node versions may fail due to modern APIs used internally.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Reference the bundled file in HTML as '/index.js' (strip the directory and ts extension).","message":"Entry point output filename determines the URL path. E.g., 'src/index.ts' produces '/index.js' and '/index.css'.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Mount the router at the root: app.use(devRouter({...}))","cause":"Middleware mounted at a subpath (e.g., app.use('/assets', devRouter(...))) but reloader path is hardcoded to '/reloader'.","error":"Error: The reloader endpoint is not found at /assets/reloader"},{"fix":"Install esbuild >=0.17: npm install -D esbuild","cause":"esbuild peer dependency not installed or version <0.17.","error":"TypeError: Cannot read properties of undefined (reading 'build')"},{"fix":"Use ESM imports (import devRouter from 'esbuild-dev-router') or enable ESM in your project.","cause":"Using CommonJS require() to load the package.","error":"Error: esbuild-dev-router is ESM-only, require() is not supported"},{"fix":"Provide an entryPoints array: devRouter({ entryPoints: ['src/index.ts'] })","cause":"Missing or empty 'entryPoints' option in the config.","error":"Build failed: No entry point provided"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}