Registry / web-framework / rsbuild-dev-middleware

rsbuild-dev-middleware

JSON →
library0.3.0jsnpmunverified

This is an express-style development middleware for webpack that serves files emitted from webpack in memory (not written to disk) and delays requests until compilation completes. This package is a direct fork/rename of webpack-dev-middleware (the original) but maintained under the Rsbuild project. Version 0.3.0 supports Node >= 18.12.0, webpack 5 as peer dependency, and ships TypeScript types. Unlike webpack-dev-server it works with custom Node.js HTTP servers like Express. Release cadence is moderate with breaking changes possible before 1.0. Key differentiator: provides fine-grained control over serving webpack assets in custom server setups without extra overhead.

npm install rsbuild-dev-middleware
INSTALL
IMPORT
SIG · RSBUILD-DEV-MIDDLE
R
rsbuild-dev-middleware
web-frameworkjavascriptv0.3.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

default
import middleware from 'webpack-dev-middleware';
const middleware = require('webpack-dev-middleware').default;
Package uses default export; in CommonJS you must use middleware = require('webpack-dev-middleware') directly.
getFilenameFromUrl
import { getFilenameFromUrl } from 'webpack-dev-middleware';
const { getFilenameFromUrl } = require('webpack-dev-middleware');
Named export is available; CJS destructuring also works but ensure you are not using .default.
setupOutputFileSystem
import { setupOutputFileSystem } from 'webpack-dev-middleware';
import setupOutputFileSystem from 'webpack-dev-middleware';
This is a named utility function, not a default export.

Sets up webpack-dev-middleware with Express, serving in-memory bundled files on the root path without writing to disk.

import webpack from 'webpack'; import middleware from 'webpack-dev-middleware'; import express from 'express'; const compiler = webpack({ // your webpack config here entry: './src/index.js', output: { path: '/', filename: 'bundle.js' }, }); const app = express(); app.use( middleware(compiler, { publicPath: '/', writeToDisk: false, // default }) ); app.listen(3000, () => console.log('Server running on http://localhost:3000'));
Debug
Known issues
breakingNode.js version requirement: v0.3.0 requires Node >= 18.12.0, dropping support for older versions.
fix
Upgrade Node.js to v18.12.0 or later.
affects: >=0.3.0
deprecatedThe package is a fork/rename; the original webpack-dev-middleware is still maintained. Ensure you use the correct package name.
fix
If you intended to use the original, revert to 'webpack-dev-middleware' from npm.
affects: >=0.1.0
gotchaThe publicPath option is not directly modifiable after middleware creation; changes to webpack config output.publicPath are not reflected until re-creation.
fix
Set publicPath explicitly in options when creating middleware or restart the server.
affects: >=0.1.0
gotchaUsing writeToDisk: true may cause stale files if webpack recompiles and you rely only on disk writes; the middleware still serves from memory.
fix
For file-based serving, consider using webpack-dev-server or manual file watching.
affects: >=0.1.0
breakingIn v0.2.0 logger style unified with Rsbuild – custom log format may differ from previous versions.
fix
Adjust any custom log parsing; see Rsbuild logger documentation.
affects: >=0.2.0 <0.3.0
Errors
Common errors & fixes
Cannot find module 'webpack'
webpack is a peer dependency but not installed.
fix
Run 'npm install webpack@^5' to add webpack as a dependency.
TypeError: middleware is not a function
Incorrect import: using default import incorrectly or destructuring wrong export.
fix
Ensure correct import: for ESM use `import middleware from 'webpack-dev-middleware'`; for CJS use `const middleware = require('webpack-dev-middleware')`.
Error: require() of ES Module not supported
Package is ESM-only; calling require() on it in a CommonJS module without dynamic import.
fix
Convert to ESM (type: module in package.json) or use dynamic import: `const middleware = await import('webpack-dev-middleware')`.
Upgrade
Version history
0.3.0latest on npm
Audit
Dependencies
webpackrequiredPeer dependency required for compilation and bundling
Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
rsbuild-dev-middleware — npm install rsbuild-dev-middleware · libregistry