A webpack plugin that clears modules from Node.js require.cache after the webpack compilation's afterEmit hook. Version 0.0.5, stable but limited maintenance. It accepts an array of regex patterns; during compilation, each cached module path is tested and removed if it matches. Primarily useful for development with npm-linked packages that need cache invalidation on rebuild. Works with webpack and Next.js servers. Simpler than using Nodemon or chokidar-based solutions, but limited to webpack-based projects.
npm install webpack-clear-require-cache-pluginVerified import paths — ran on the pinned version, not inferred.
Shows basic usage: import the plugin function and pass an array of regex patterns to clear require cache for linked modules.
Ensure you only use this plugin in server-side webpack configurations.
Consider using native webpack module federation or dedicated cache-clearing plugins for modern webpack.
Use patterns like /node_modules\/my-module/ to avoid clearing unrelated modules.
Disable filesystem cache when using this plugin: config.cache = false.
Use clearRequireCachePlugin([...]) without 'new'.
Run npm install --save-dev webpack-clear-require-cache-plugin and require with correct casing.
Change to const clearRequireCachePlugin = require('webpack-clear-require-cache-plugin');No dependency data recorded yet.