
Security News
Open Source CAI Framework Handles Pen Testing Tasks up to 3,600× Faster Than Humans
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
vite-plugin-virtual
Advanced tools
Virtual modules with HMR plugin for Vite
Install Vite Plugin Virtual:
$ npm install -D vite-plugin-virtual
Add to your vite.config.js
:
import virtual from 'vite-plugin-virtual'
export default {
plugins: [
virtual({
'virtual:module': `export default { hello: 'world' }`,
'virtual:config': { hello: 'world' }
})
]
}
In your sources you can now import the virtual modules
import obj from 'virtual:config'
console.log(obj)
You can update the virtual module during dev
import virtual, { updateVirtualModule } from 'vite-plugin-virtual'
const plugin = virtual({
'virtual:module': `export default { hello: 'world' }`,
'virtual:config': { hello: 'world' },
'virtual:lazy': () => `Hello ${'computed'} world`,
})
updateVirtualModule(plugin, 'virtual:config', { hello: 'new message' })
You can invalidate the virtual module during dev in case the config changes
import virtual, { invalidateVirtualModule } from 'vite-plugin-virtual'
const modules = {
'virtual:module': `export default { hello: 'world' }`,
'virtual:config': { hello: 'world' }
}
const plugin = virtual(modules)
const server: ViteDevServer
modules['virtual:config'] = { hello: 'new message' }
invalidateVirtualModule(server, 'virtual:config')
To enable TypeScript IntelliSense for a virtual module, you can use ambient modules to declare the module in a .d.ts
file included by your TS setup:
declare module 'virtual:config' {
export const hello: string;
}
For more details refer to the TypeScript docs for ambient modules.
MIT License © 2021 patak-js
FAQs
Virtual modules with HMR invalidation plugin for Vite
The npm package vite-plugin-virtual receives a total of 6,936 weekly downloads. As such, vite-plugin-virtual popularity was classified as popular.
We found that vite-plugin-virtual demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.