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.
Common errors
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'
Warnings
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.
Install
npm install wipe-webpack-cache yarn add wipe-webpack-cache pnpm add wipe-webpack-cache Imports
- wipe wrong
const wipe = require('wipe-webpack-cache')correctimport { wipe } from 'wipe-webpack-cache' - default wrong
const wipe = require('wipe-webpack-cache').defaultcorrectimport wipe from 'wipe-webpack-cache' - wipeNodeCache wrong
const wipeNodeCache = require('wipe-webpack-cache')correctimport { wipeNodeCache } from 'wipe-node-cache'
Quickstart
import { wipe } from 'wipe-webpack-cache';
// Wipe all modules except those in node_modules
wipe(null, (fileName) => !fileName.includes('node_modules'));