vite-plugin-override-deps
v0.1.1
Published
> 🧩 Intercept and override dependencies at build-time with Vite.
Downloads
15
Maintainers
Readme
Override deps at runtime
🧩 Intercept and override dependencies at build-time with Vite.
A lightweight Vite plugin that lets you replace, extend,
or patch libraries (like React, Zustand, etc.) using custom virtual modules —
without forking or touching node_modules.
Getting Started
npm install vite-plugin-override-deps -Dor, if using pnpm:
pnpm add vite-plugin-override-deps -DUsage
Add the plugin to your vite.config.ts:
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import {overrideDeps} from "vite-plugin-override-deps";
export default defineConfig({
plugins: [
overrideDeps({
targets: [
{
package: "react",
overrides: {
useMemo: (o) => `(...args) => {
console.log("Custom useMemo!");
return ${o}.useMemo(...args);
}`
}
}
]
}),
react(),
]
});Now every import from "react" will be rewritten to a virtual version that exports all React APIs but uses your custom useMemo.
Why
- Patch libraries without forking
- Log or instrument internal behavior
Issues
If you encounter any issue, please open an issue here.
License
Distributed under the MIT License. See LICENSE file for more details.
© 2025 Hichem Taboukouyout
If you found this package helpful, consider leaving a star! ⭐️
