A Vite plugin (v0.1.0) that enables transparent wrapping of matched modules with custom implementations. It intercepts module resolution and loading, allowing developers to replace module content while preserving the original module's identity. Designed for building higher-level Vite plugins and virtual module systems. It is a lightweight alternative to Rollup's `this.resolve` and virtual plugin patterns, providing a cleaner API for module wrapping. Requires Vite >=7. Ships TypeScript types.
npm install vite-plugin-wrapperVerified import paths — ran on the pinned version, not inferred.
Wraps virtual:bar by adding a foo property to the exported object.
Upgrade Vite to version 7 or later.
Use `async load(id) { return '...'; }` if you need async, but ensure the final return is a string.If you need to match file paths, use `resolveId.filter.filePath` instead of `id`.
Change to `import { wrapper } from 'vite-plugin-wrapper'`Ensure you use `import { wrapper } from 'vite-plugin-wrapper'` and call it as a function.