esbuild-dev-server

raw JSON →
0.1.2 verified Fri May 01 auth: no javascript

esbuild-dev-server (v0.1.2) provides a hot-reloading development server powered by esbuild, automatically rebuilding and refreshing the browser on file changes. It is designed for minimal configuration and fast iteration, wrapping esbuild's rebuild API with a simple HTTP server. Currently experimental, it requires esbuild ^0.12.9 as a peer dependency. Key differentiator: lightweight alternative to webpack-dev-server for esbuild users.

error Error [ERR_REQUIRE_ESM]: require() of ES Module
cause Using CommonJS require() to import an ESM-only package.
fix
Change require() to import or use dynamic import().
error Error: Cannot find module 'esbuild'
cause Missing peer dependency esbuild.
fix
Install esbuild: npm install esbuild
error TypeError: createServer is not a function
cause Incorrect import of the default export as a function.
fix
Use named import: import { createServer } from 'esbuild-dev-server'
breaking The package requires esbuild ^0.12.9. Older versions of esbuild are incompatible.
fix Update esbuild to ^0.12.9.
deprecated The legacy 'esbuild-dev' npm package is deprecated; use 'esbuild-dev-server'.
fix Migrate to esbuild-dev-server and update imports.
gotcha The package does not work in browsers; it is a Node.js only server tool.
fix Use only in Node.js environment.
gotcha The package is ESM-only. Using CommonJS require() will throw an error.
fix Use import syntax or switch to dynamic import.
npm install esbuild-dev-tool
yarn add esbuild-dev-tool
pnpm add esbuild-dev-tool

Initializes a development server with esbuild configuration and a static file directory.

import { createServer } from 'esbuild-dev-server';
import esbuild from 'esbuild';

const server = createServer({
  build: {
    entryPoints: ['src/index.js'],
    bundle: true,
    outfile: 'dist/bundle.js',
  },
  server: {
    port: 3000,
    static: 'public',
  },
});

server.start().then(() => {
  console.log('Dev server running on http://localhost:3000');
});