wipe-webpack-cache

raw JSON →
2.1.0 verified Sat Apr 25 auth: no javascript

Wipes webpack internal module cache in a controlled way for testing and mocking. Version 2.1.0 is stable; low release cadence. Requires NamedModulesPlugin and HotModuleReplacementPlugin in webpack config. Provides a filter-and-bubble approach to selectively clear cache entries. Useful with proxyquire and similar testing libraries.

error Cannot find module 'wipe-webpack-cache'
cause Package not installed or import path incorrect.
fix
Run npm install --save-dev wipe-webpack-cache
error wipe is not a function
cause Incorrect import style (e.g., using default export incorrectly).
fix
Use import { wipe } from 'wipe-webpack-cache' or import wipe from 'wipe-webpack-cache'
gotcha Requires NamedModulesPlugin and HotModuleReplacementPlugin in webpack config, or it will not work correctly.
fix Add new webpack.NamedModulesPlugin() and new webpack.HotModuleReplacementPlugin() to plugins array.
npm install wipe-webpack-cache
yarn add wipe-webpack-cache
pnpm add wipe-webpack-cache

Shows how to import and use the wipe function to clear module cache for testing.

import { wipe } from 'wipe-webpack-cache';

// Wipe all modules except those in node_modules
wipe(null, (fileName) => !fileName.includes('node_modules'));