Registry / devops / hard-source-webpack-plugin

hard-source-webpack-plugin

JSON →
library0.13.1jsnpmunverified

HardSourceWebpackPlugin is a webpack plugin that provides intermediate caching of module compilation results to disk, drastically speeding up subsequent builds (second build is significantly faster). Version 0.13.1 is the latest stable release, last updated in 2020. It works by caching the output of webpack's module resolution and transformation steps, using a configurable cache directory and hash-based invalidation. Key differentiators: it caches at the module level (not just the entire bundle), supports parallel builds via ParallelModulePlugin, and allows excluding specific modules. However, it is no longer maintained and may have compatibility issues with modern webpack versions (5+), making it less suitable for new projects compared to persistent caching built into webpack 5.

npm install hard-source-webpack-plugin
INSTALL
IMPORT
SIG · HARD-SOURCE-WEBPAC
H
hard-source-webpack-plugin
devopsjavascriptv0.13.1
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.

HardSourceWebpackPlugin
const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
import HardSourceWebpackPlugin from 'hard-source-webpack-plugin'; // ESM not supported
The package only supports CommonJS (require). Using ES6 import will fail.
HardSourceWebpackPlugin.ExcludeModulePlugin
const { ExcludeModulePlugin } = require('hard-source-webpack-plugin');
import { ExcludeModulePlugin } from 'hard-source-webpack-plugin'; // ESM not supported
ExcludeModulePlugin is a static property on HardSourceWebpackPlugin; destructure require or access via HardSourceWebpackPlugin.ExcludeModulePlugin.
HardSourceWebpackPlugin.ParallelModulePlugin
const { ParallelModulePlugin } = require('hard-source-webpack-plugin');
const ParallelModulePlugin = require('hard-source-webpack-plugin/parallel'); // wrong path
ParallelModulePlugin is available as a static property of the main export, not as a separate module.

Shows basic webpack configuration with HardSourceWebpackPlugin for caching modules to disk.

// webpack.config.js const HardSourceWebpackPlugin = require('hard-source-webpack-plugin'); module.exports = { entry: './src/index.js', output: { filename: 'bundle.js', path: __dirname + '/dist' }, plugins: [ new HardSourceWebpackPlugin({ cacheDirectory: 'node_modules/.cache/hard-source/[confighash]', info: { mode: 'none', level: 'warn' }, }), ], };
Debug
Known issues
deprecatedPackage is no longer maintained (last release 2020) and may not work with webpack 5+.
fix
Use webpack 5's built-in persistent caching (cache: { type: 'filesystem' }) instead. For webpack 4, consider using babel-loader's cacheDirectory or other caching strategies.
affects: >=0.13.0
breakingHardSourceWebpackPlugin may cause memory leaks or build failures with certain loaders, especially mini-css-extract-plugin.
fix
Use ExcludeModulePlugin to exclude problematic loaders, or switch to webpack 5 persistent cache.
affects: >=0.13.0
gotchaFirst build is not cached; only subsequent builds benefit. Cache must be manually cleared if build configuration changes unexpectedly.
fix
Delete the cache directory or use the configHash and environmentHash options to ensure cache invalidation.
affects: *
gotchaThe package does not support ES module imports (import). Only CommonJS require() works.
fix
Use const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
affects: *
gotchaParallelModulePlugin is experimental and may cause issues with webpack-dev-server or hot module replacement.
fix
Avoid using ParallelModulePlugin with dev server; consider using webpack's built-in parallelism (webpack 5) or thread-loader.
affects: >=0.13.0
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'hard-source-webpack-plugin'
Package not installed or mistaken import path.
fix
Run npm install --save-dev hard-source-webpack-plugin and ensure the require path is correct.
Error: HardSourceWebpackPlugin is not a constructor
Using ES6 import instead of CommonJS require.
fix
Change import HardSourceWebpackPlugin from ... to const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
TypeError: Cannot read property 'tap' of undefined
Incompatible version of webpack; HardSourceWebpackPlugin may call hooks not present in webpack 5.
fix
Downgrade webpack to version 4, or migrate to webpack 5 persistent cache.
Build fails silently with no errors after first build (assets not emitted)
Known issue with mini-css-extract-plugin where assets are not emitted on repeated builds.
fix
Add ExcludeModulePlugin to exclude mini-css-extract-loader paths. Example: new HardSourceWebpackPlugin.ExcludeModulePlugin([{ test: /mini-css-extract-plugin[\\/]dist[\\/]loader/ }])
Upgrade
Version history
0.13.1latest on npm
Audit
Dependencies
webpackrequiredRequired as a peer dependency; plugin works with webpack 4 and earlier, but not fully compatible with webpack 5.
Agent activity
6 hits · last 30 days
node
6
Resources
hard-source-webpack-plugin — npm install hard-source-webpack-plugin · libregistry