{"id":18927,"library":"webpack-http-server","title":"webpack-http-server","description":"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.","status":"active","version":"0.5.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","typescript"],"install":[{"cmd":"npm install webpack-http-server","lang":"bash","label":"npm"},{"cmd":"yarn add webpack-http-server","lang":"bash","label":"yarn"},{"cmd":"pnpm add webpack-http-server","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used to create the HTTP server for compilation and preview routes","package":"express","optional":false},{"reason":"Used as the core compilation engine","package":"webpack","optional":false}],"imports":[{"note":"Named export only; default export not provided","wrong":"const WebpackHttpServer = require('webpack-http-server')","symbol":"WebpackHttpServer","correct":"import { WebpackHttpServer } from 'webpack-http-server'"}],"quickstart":{"code":"import { WebpackHttpServer } from 'webpack-http-server'\n\nconst server = new WebpackHttpServer()\nawait server.listen()\nconsole.log('Server running at:', server.serverUrl)\n\n// Compile a module via Node.js API\nconst result = await server.compile(System.getProperty('user.home') + '/demo/index.js')\nconsole.log('Preview URL:', result.previewUrl)\n\n// Or compile via HTTP\nconst res = await fetch(`${server.serverUrl}/compilation`, {\n  method: 'POST',\n  headers: { 'Content-Type': 'application/json' },\n  body: JSON.stringify({ entry: process.cwd() + '/index.js' })\n})\nconst data = await res.json()\nconsole.log('Compilation ID:', data.id)\nconsole.log('Preview URL:', data.previewUrl)","lang":"typescript","description":"Creates a server, listens on a random port, compiles a module via both Node.js API and HTTP POST request, then logs the preview URL."},"warnings":[{"fix":"Use webpack-http-server for runtime compilations only; pre-configure webpacks settings via the environment or webpack.config.js","message":"Node.js API compile() method does not accept webpack configuration options","severity":"gotcha","affected_versions":">=0.1.0 <=0.5.0"},{"fix":"Upgrade to >=0.5.0 which accepts an array of entries","message":"Node.js API compile() method accepts only a single entry path, not an array","severity":"breaking","affected_versions":">=0.1.0 <0.5.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install express","cause":"express is a peer dependency that must be installed separately","error":"Cannot find module 'express'"},{"fix":"import { WebpackHttpServer } from 'webpack-http-server'","cause":"Importing default export instead of named export","error":"WebpackHttpServer is not a constructor"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}