Registry / http-networking / vite-plugin-wrapper

vite-plugin-wrapper

JSON →
library0.1.0jsnpmunverified

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-wrapper
INSTALL
IMPORT
SIG · VITE-PLUGIN-WRAPPE
V
vite-plugin-wrapper
http-networkingjavascriptv0.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

wrapper
import { wrapper } from 'vite-plugin-wrapper'
import wrapper from 'vite-plugin-wrapper'
Named export, not default. TypeScript types are bundled.

Wraps virtual:bar by adding a foo property to the exported object.

import { defineConfig } from 'vite'; import { wrapper } from 'vite-plugin-wrapper'; export default defineConfig({ plugins: [ wrapper({ resolveId: { filter: { id: /^virtual:bar$/ }, }, load(id) { return ` import mod from ${JSON.stringify(id)}; export default { ...mod, foo: 'foo' }; `; }, }), ], });
Debug
Known issues
breakingRequires Vite >=7. Do not use with older Vite versions.
fix
Upgrade Vite to version 7 or later.
affects: <7
gotchaThe `load` function must return a string. Returning a Promise is not supported.
fix
Use `async load(id) { return '...'; }` if you need async, but ensure the final return is a string.
affects: all
gotchaThe filter `id` property only matches module IDs, not file paths. Use `filePath` for file system paths.
fix
If you need to match file paths, use `resolveId.filter.filePath` instead of `id`.
affects: all
Errors
Common errors & fixes
Error: No matching export in 'vite-plugin-wrapper' for import 'wrapper'
Using a default import instead of a named import.
fix
Change to `import { wrapper } from 'vite-plugin-wrapper'`
TypeError: wrapper is not a function
Possibly using default import if the named export is not called correctly.
fix
Ensure you use `import { wrapper } from 'vite-plugin-wrapper'` and call it as a function.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
viterequiredPeer dependency: the plugin hooks into Vite's module graph and requires Vite >=7.
Agent activity
10 hits · last 30 days
node
8
OpenAI (training)
1
Resources
vite-plugin-wrapper — npm install vite-plugin-wrapper · libregistry