webpack-http-server
raw JSON → 0.5.0 verified Sat Apr 25 auth: no javascript
An on-demand runtime webpack compilation over HTTP, version 0.5.0. It acts as an Express server that accepts compilation requests via HTTP POST or Node.js API, returning a unique preview URL for each compiled module. The server runs on a random port and allows dynamic entrypoints, unlike webpack-dev-server which is scoped to a single compilation. Key differentiators include per-request compilation IDs, preview routes, and a focus on example-driven testing workflows. Released as a lightweight alternative to static compilation setups.
Common errors
error Cannot find module 'express' ↓
cause express is a peer dependency that must be installed separately
fix
npm install express
error WebpackHttpServer is not a constructor ↓
cause Importing default export instead of named export
fix
import { WebpackHttpServer } from 'webpack-http-server'
Warnings
gotcha Node.js API compile() method does not accept webpack configuration options ↓
fix Use webpack-http-server for runtime compilations only; pre-configure webpacks settings via the environment or webpack.config.js
breaking Node.js API compile() method accepts only a single entry path, not an array ↓
fix Upgrade to >=0.5.0 which accepts an array of entries
Install
npm install webpack-http-server yarn add webpack-http-server pnpm add webpack-http-server Imports
- WebpackHttpServer wrong
const WebpackHttpServer = require('webpack-http-server')correctimport { WebpackHttpServer } from 'webpack-http-server'
Quickstart
import { WebpackHttpServer } from 'webpack-http-server'
const server = new WebpackHttpServer()
await server.listen()
console.log('Server running at:', server.serverUrl)
// Compile a module via Node.js API
const result = await server.compile(System.getProperty('user.home') + '/demo/index.js')
console.log('Preview URL:', result.previewUrl)
// Or compile via HTTP
const res = await fetch(`${server.serverUrl}/compilation`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ entry: process.cwd() + '/index.js' })
})
const data = await res.json()
console.log('Compilation ID:', data.id)
console.log('Preview URL:', data.previewUrl)