{"id":22934,"library":"vite-plugin-wrapper","title":"vite-plugin-wrapper","description":"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.","status":"active","version":"0.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/magne4000/vite-plugin-wrapper","tags":["javascript","vite","vite-plugin","wrapper","module-wrapper","virtual-module","rollup","bundler","esm","typescript"],"install":[{"cmd":"npm install vite-plugin-wrapper","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-wrapper","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-wrapper","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: the plugin hooks into Vite's module graph and requires Vite >=7.","package":"vite","optional":false}],"imports":[{"note":"Named export, not default. TypeScript types are bundled.","wrong":"import wrapper from 'vite-plugin-wrapper'","symbol":"wrapper","correct":"import { wrapper } from 'vite-plugin-wrapper'"}],"quickstart":{"code":"import { defineConfig } from 'vite';\nimport { wrapper } from 'vite-plugin-wrapper';\n\nexport default defineConfig({\n  plugins: [\n    wrapper({\n      resolveId: {\n        filter: { id: /^virtual:bar$/ },\n      },\n      load(id) {\n        return `\nimport mod from ${JSON.stringify(id)};\nexport default { ...mod, foo: 'foo' };\n`;\n      },\n    }),\n  ],\n});","lang":"typescript","description":"Wraps virtual:bar by adding a foo property to the exported object."},"warnings":[{"fix":"Upgrade Vite to version 7 or later.","message":"Requires Vite >=7. Do not use with older Vite versions.","severity":"breaking","affected_versions":"<7"},{"fix":"Use `async load(id) { return '...'; }` if you need async, but ensure the final return is a string.","message":"The `load` function must return a string. Returning a Promise is not supported.","severity":"gotcha","affected_versions":"all"},{"fix":"If you need to match file paths, use `resolveId.filter.filePath` instead of `id`.","message":"The filter `id` property only matches module IDs, not file paths. Use `filePath` for file system paths.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Change to `import { wrapper } from 'vite-plugin-wrapper'`","cause":"Using a default import instead of a named import.","error":"Error: No matching export in 'vite-plugin-wrapper' for import 'wrapper'"},{"fix":"Ensure you use `import { wrapper } from 'vite-plugin-wrapper'` and call it as a function.","cause":"Possibly using default import if the named export is not called correctly.","error":"TypeError: wrapper is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}