Gathering detailed insights and metrics for webpack-virtual-modules-ng
Gathering detailed insights and metrics for webpack-virtual-modules-ng
Gathering detailed insights and metrics for webpack-virtual-modules-ng
Gathering detailed insights and metrics for webpack-virtual-modules-ng
npm install webpack-virtual-modules-ng
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
508 Stars
124 Commits
42 Forks
20 Watching
1 Branches
32 Contributors
Updated on 11 Nov 2024
TypeScript (97.41%)
JavaScript (2.59%)
Cumulative downloads
Total Downloads
Last day
0%
2
Compared to previous day
Last week
55.6%
14
Compared to previous week
Last month
30.4%
60
Compared to previous month
Last year
2%
614
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
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 9/30 approved changesets -- score normalized to 3
Reason
2 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 3
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 2024-11-18
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