Gathering detailed insights and metrics for webpack-virtual-modules-fix-refresh
Gathering detailed insights and metrics for webpack-virtual-modules-fix-refresh
npm install webpack-virtual-modules-fix-refresh
Typescript
Module System
Node Version
NPM Version
TypeScript (97.41%)
JavaScript (2.59%)
Total Downloads
19,286
Last Day
10
Last Week
74
Last Month
192
Last Year
3,193
512 Stars
124 Commits
42 Forks
20 Watching
1 Branches
32 Contributors
Latest Version
0.4.6
Package Id
webpack-virtual-modules-fix-refresh@0.4.6
Unpacked Size
45.86 kB
Size
11.83 kB
File Count
14
NPM Version
8.1.4
Node Version
14.16.0
Cumulative downloads
Total Downloads
Last day
100%
10
Compared to previous day
Last week
54.2%
74
Compared to previous week
Last month
11%
192
Compared to previous month
Last year
-45.7%
3,193
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.
Copyright © 2017 SysGears INC. 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
0 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
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
security policy file not detected
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-01-27
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