A webpack plugin (v0.0.12, latest as of 2025) that replaces imported modules at build time, allowing monkey patching of third-party libraries without modifying source code. Designed for webpack 3.x only. Uses regex-based matching to swap `require`/`import` statements. No updates since 2018; limited compatibility and no support for webpack 4+ or ESM. Different from string-replace-loader as it operates on module resolution rather than string substitution.
npm install module-replace-webpack-pluginVerified import paths — ran on the pinned version, not inferred.
Configures webpack to replace all imports matching /lodash/ with a local patched file, excluding the patched file itself from replacement.
Upgrade to a modern alternative like string-replace-loader or NormalModuleReplacementPlugin.
Use path.resolve(__dirname, 'src/patched.js') to specify absolute path.
Order specific regexes before generic ones in the modules array.
Always include file extension, e.g., './patched.js' not './patched'.
Use const ModuleReplaceWebpackPlugin = require('module-replace-webpack-plugin');Ensure options contains modules: [{ test: /.../, replace: '...' }]