Gathering detailed insights and metrics for webpack-virtual-modules
Gathering detailed insights and metrics for webpack-virtual-modules
Gathering detailed insights and metrics for webpack-virtual-modules
Gathering detailed insights and metrics for webpack-virtual-modules
@types/webpack-virtual-modules
Stub TypeScript definitions entry for webpack-virtual-modules, which provides its own types definitions
@nut-project/webpack-virtual-modules
webpack-virtual-modules
webpack-virtual-modules-ng
Webpack Virtual Modules
webpack-virtual-modules-fix-refresh
Webpack Virtual Modules
Webpack Virtual Modules is a webpack plugin that lets you create, modify, and delete in-memory files in a way that webpack treats them as if they were physically presented in the file system.
npm install webpack-virtual-modules
Typescript
Module System
99.2
Supply Chain
99.5
Quality
79.3
Maintenance
100
Vulnerability
100
License
TypeScript (97.41%)
JavaScript (2.59%)
Total Downloads
1,681,125,343
Last Day
2,561,531
Last Week
13,324,138
Last Month
58,320,301
Last Year
583,484,338
MIT License
515 Stars
125 Commits
42 Forks
19 Watchers
1 Branches
32 Contributors
Updated on Apr 08, 2025
Minified
Minified + Gzipped
Latest Version
0.6.2
Package Id
webpack-virtual-modules@0.6.2
Unpacked Size
45.36 kB
Size
10.59 kB
File Count
11
Published on
Jun 04, 2024
Cumulative downloads
Total Downloads
Last Day
47.9%
2,561,531
Compared to previous day
Last Week
3.4%
13,324,138
Compared to previous week
Last Month
-5.6%
58,320,301
Compared to previous month
Last Year
33%
583,484,338
Compared to previous year
25
Webpack Virtual Modules is a plugin that allows for dynamical generation of in-memory virtual modules for JavaScript builds created with webpack. When virtual module is created all the parent virtual dirs that lead to the module filename are created too. This plugin supports watch mode meaning any write to a virtual module is seen by webpack as if a real file stored on disk has changed.
Use NPM or Yarn to install Webpack Virtual Modules as a development dependency:
1# with NPM 2npm install webpack-virtual-modules --save-dev 3 4# with Yarn 5yarn add webpack-virtual-modules --dev
You can use Webpack Virtual Modules with webpack 5, 4 and 3. The examples below show the usage with webpack 5 or 4. If you want to use our plugin with webpack 3, check out a dedicated doc:
Require the plugin in the webpack configuration file, then create and add virtual modules in the plugins
array in the
webpack configuration object:
1var VirtualModulesPlugin = require('webpack-virtual-modules');
2
3var virtualModules = new VirtualModulesPlugin({
4 'node_modules/module-foo.js': 'module.exports = { foo: "foo" };',
5 'node_modules/module-bar.js': 'module.exports = { bar: "bar" };'
6});
7
8module.exports = {
9 // ...
10 plugins: [
11 virtualModules
12 ]
13};
You can now import your virtual modules anywhere in the application and use them:
1var moduleFoo = require('module-foo'); 2// You can now use moduleFoo 3console.log(moduleFoo.foo);
You can generate virtual modules dynamically with Webpack Virtual Modules.
Here's an example of dynamic generation of a module. All you need to do is create new virtual modules using the plugin
and add them to the plugins
array. After that, you need to add a webpack hook. For using hooks, consult webpack
compiler hook documentation.
1var webpack = require('webpack'); 2var VirtualModulesPlugin = require('webpack-virtual-modules'); 3 4// Create an empty set of virtual modules 5const virtualModules = new VirtualModulesPlugin(); 6 7var compiler = webpack({ 8 // ... 9 plugins: [ 10 virtualModules 11 ] 12}); 13 14compiler.hooks.compilation.tap('MyPlugin', function(compilation) { 15 virtualModules.writeModule('node_modules/module-foo.js', ''); 16}); 17 18compiler.watch();
In other module or a Webpack plugin, you can write to the module module-foo
whatever you need. After this write,
webpack will "see" that module-foo.js
has changed and will restart compilation.
1virtualModules.writeModule(
2 'node_modules/module-foo.js',
3 'module.exports = { foo: "foo" };'
4);
This project is inspired by virtual-module-webpack-plugin.
This project uses nari package manager to have reproducible builds without resorting to lockfiles, it uses lockTime
field in package.json
instead.
To install nari
execute:
npm i -g nari
And then nari
to install the project.
To run project scripts use nari script_name
, for example nari test
to run unit tests.
Copyright © 2017 SysGears (Cyprus) Limited. This source code is licensed under the MIT license.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
Found 9/30 approved changesets -- score normalized to 3
Reason
1 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-04-28
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More