Registry / devops / run-script-webpack-plugin

run-script-webpack-plugin

JSON →
library0.2.3jsnpmunverified

run-script-webpack-plugin is a utility Webpack plugin designed to automatically execute a specified script after Webpack completes its build process, primarily intended for development environments. As of its current stable version, 0.2.3, published approximately a year ago, the project appears to maintain a stable and perhaps slower release cadence. This plugin is particularly useful for server-side bundles, enabling automatic restarts or reloads during development workflows. A key differentiator is its strong TypeScript typing, having been re-implemented from scratch based on the functionality of start-server-webpack-plugin. It offers configurable options for passing arguments to Node.js and the script, managing auto-restarts, sending signals for Hot Module Reloading (HMR), and enabling keyboard-initiated restarts. [1, 2]

npm install run-script-webpack-plugin
INSTALL
IMPORT
SIG · RUN-SCRIPT-WEBPACK
R
run-script-webpack-plugin
devopsjavascriptv0.2.3
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.

RunScriptWebpackPlugin
import { RunScriptWebpackPlugin } from 'run-script-webpack-plugin';
const { RunScriptWebpackPlugin } = require('run-script-webpack-plugin');
The library ships with TypeScript types and is designed for ESM import in modern Webpack configurations.

This example demonstrates how to integrate `RunScriptWebpackPlugin` into a Webpack configuration to automatically run a compiled server-side script, enable debugging, and configure HMR signals for development.

import { RunScriptWebpackPlugin } from "run-script-webpack-plugin"; import type { Configuration } from 'webpack'; const config: Configuration = { entry: { server: './src/server.ts' }, output: { filename: '[name].js', path: '/dist', }, plugins: [ // Only use this in DEVELOPMENT new RunScriptWebpackPlugin({ name: 'server.js', nodeArgs: ['--inspect'], // allow debugging args: ['scriptArgument1', 'scriptArgument2'], // pass args to script autoRestart: true, // Should the script auto-restart after emit. Defaults to true. signal: 'SIGUSR2', // signal to send for HMR (defaults to `false`, uses 'SIGUSR2' if `true`) keyboard: true, // Allow typing 'rs' to restart the server. cwd: undefined, // set a current working directory for the child process }), ], // ... other webpack configuration (e.g., target: 'node', mode: 'development') }; export default config;
Debug
Known issues
gotchaThis plugin is explicitly designed for DEVELOPMENT environments and should not be used in production builds. Its functionality, such as automatic restarts, is unsuitable for a production server lifecycle.
fix
Ensure the plugin is conditionally included in your Webpack configuration only for `development` mode or when `process.env.NODE_ENV === 'development'`.
affects: >=0.1.0
gotchaWhen using Hot Module Reloading (HMR) with server-side code and `webpack-node-externals`, you must whitelist `webpack/hot/poll` or `webpack/hot/signal` modules to ensure they are bundled with your server code, as they are essential for HMR functionality.
fix
Modify your `webpack-node-externals` configuration to include these modules in its whitelist, e.g., `whitelist: ['webpack/hot/poll', /^webpack\/hot\//]`.
affects: >=0.1.0
gotchaCompatibility with major Webpack versions is crucial. While not explicitly stated for this plugin, Webpack itself has undergone significant breaking changes (e.g., from v4 to v5) that could affect plugin behavior. Always test thoroughly when upgrading Webpack.
fix
Consult the `webpack` migration guides (e.g., `webpack-cli` changelog for Node.js and Webpack version requirements) and ensure your Webpack version and configuration align with the plugin's expected environment. [5, 8]
affects: All
Errors
Common errors & fixes
Multiple entries found, please specify 'name' option.
The Webpack configuration has multiple entry points, but the `RunScriptWebpackPlugin` was initialized without specifying which compiled asset (`name`) to execute.
fix
Provide the `name` option to `RunScriptWebpackPlugin` matching the desired entry point's output filename, e.g., `new RunScriptWebpackPlugin({ name: 'server.js' })`.
Hot Module Reloading (HMR) is not working as expected with my server bundle.
Often due to `webpack-node-externals` preventing Webpack's HMR client modules (`webpack/hot/poll` or `webpack/hot/signal`) from being bundled with the server, leading to HMR not initiating or failing silently.
fix
Ensure `webpack/hot/poll` or `webpack/hot/signal` are explicitly whitelisted in your `webpack-node-externals` configuration.
Upgrade
Version history
0.2.3latest on npm
Audit
Dependencies
webpackrequiredRequired as a peer dependency for any webpack plugin to function.
Agent activity
4 hits · last 30 days
node
4
Resources
run-script-webpack-plugin — npm install run-script-webpack-plugin · libregistry