
Research
/Security News
Intercom’s npm Package Compromised in Ongoing Mini Shai-Hulud Worm Attack
Compromised intercom-client@7.0.4 npm package is tied to the ongoing Mini Shai-Hulud worm attack targeting developer and CI/CD secrets.
@rollup/plugin-virtual
Advanced tools
🍣 A Rollup plugin which loads virtual modules from memory.
This plugin requires an LTS Node version (v14.0.0+) and Rollup v1.20.0+.
Using npm:
npm install @rollup/plugin-virtual --save-dev
Note. Use this plugin before any others such as node-resolve or commonjs, so they do not alter the output.
Suppose an entry file containing the snippet below exists at src/entry.js, and attempts to load batman and src/robin.js from memory:
// src/entry.js
import batman from 'batman';
import robin from './robin.js';
console.log(batman, robin);
Create a rollup.config.js configuration file and import the plugin:
import virtual from '@rollup/plugin-virtual';
export default {
input: 'src/entry.js',
// ...
plugins: [
virtual({
batman: `export default 'na na na na na'`,
'src/robin.js': `export default 'batmannnnn'`
})
]
};
Then call rollup either via the CLI or the API.
This plugin has no formal options. The lone parameter for this plugin is an Object containing properties that correspond to a String containing the virtual module's code.
It's possible to use the plugin to specify an entry point for a bundle. To do so, implement a pattern simple to what is shown below:
import virtual from '@rollup/plugin-virtual';
export default {
input: 'entry',
// ...
plugins: [
virtual({
entry: `
import batman from 'batcave';
console.log(batman);
`
})
]
};
rollup-plugin-inject allows you to inject variables or modules into your bundle. While it does not create virtual modules, it can be used to achieve similar results by injecting code into existing modules.
rollup-plugin-replace allows you to replace strings in your code during the build process. It can be used to inject dynamic content or mock modules, similar to @rollup/plugin-virtual, but it operates by replacing existing code rather than creating new virtual modules.
rollup-plugin-alias allows you to create aliases for module paths. While it does not create virtual modules, it can be used to redirect module imports to different files or modules, which can be useful for testing or injecting custom implementations.
FAQs
Load virtual modules from memory
The npm package @rollup/plugin-virtual receives a total of 626,025 weekly downloads. As such, @rollup/plugin-virtual popularity was classified as popular.
We found that @rollup/plugin-virtual demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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.

Research
/Security News
Compromised intercom-client@7.0.4 npm package is tied to the ongoing Mini Shai-Hulud worm attack targeting developer and CI/CD secrets.

Research
Socket detected a malicious supply chain attack on PyPI package lightning versions 2.6.2 and 2.6.3, which execute credential-stealing malware on import.

Research
A brand-squatted TanStack npm package used postinstall scripts to steal .env files and exfiltrate developer secrets to an attacker-controlled endpoint.