New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

webpack-virtual-modules

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpack-virtual-modules - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

58

index.js

@@ -5,4 +5,2 @@ var VirtualStats = require('./virtual-stats');

var uid = process.getuid && process.getuid() || 0;
var gid = process.getgid && process.getgid() || 0;
var inode = 45000000;

@@ -35,4 +33,4 @@

nlink: 0,
uid: uid,
gid: gid,
uid: 1000,
gid: 1000,
rdev: 0,

@@ -47,3 +45,3 @@ blksize: 4096,

ctime: time,
birthtime: time,
birthtime: time
});

@@ -70,27 +68,31 @@ var modulePath = getModulePath(filePath, self._compiler);

if (self._staticModules) {
Object.keys(self._staticModules).forEach(function(path) {
self.writeModule(path, self._staticModules[path]);
});
}
compiler.plugin("after-environment", function() {
var originalPurge = compiler.inputFileSystem.purge;
compiler.inputFileSystem.purge = function() {
originalPurge.call(this, arguments);
if (this._virtualFiles) {
Object.keys(this._virtualFiles).forEach(function(file) {
var data = this._virtualFiles[file];
this._statStorage.data[file] = [null, data.stats];
this._readFileStorage.data[file] = [null, data.contents];
}.bind(this));
}
};
if (!compiler.inputFileSystem._writeVirtualFile) {
var originalPurge = compiler.inputFileSystem.purge;
compiler.inputFileSystem._writeVirtualFile = function(file, stats, contents) {
this._virtualFiles = this._virtualFiles || {};
this._virtualFiles[file] = {stats: stats, contents: contents};
this._statStorage.data[file] = [null, stats];
this._readFileStorage.data[file] = [null, contents];
};
compiler.inputFileSystem.purge = function() {
originalPurge.call(this, arguments);
if (this._virtualFiles) {
Object.keys(this._virtualFiles).forEach(function(file) {
var data = this._virtualFiles[file];
this._statStorage.data[file] = [null, data.stats];
this._readFileStorage.data[file] = [null, data.contents];
}.bind(this));
}
};
compiler.inputFileSystem._writeVirtualFile = function(file, stats, contents) {
this._virtualFiles = this._virtualFiles || {};
this._virtualFiles[file] = {stats: stats, contents: contents};
this._statStorage.data[file] = [null, stats];
this._readFileStorage.data[file] = [null, contents];
};
}
if (self._staticModules) {
Object.keys(self._staticModules).forEach(function(path) {
self.writeModule(path, self._staticModules[path]);
});
delete self._staticModules;
}
});

@@ -97,0 +99,0 @@

{
"name": "webpack-virtual-modules",
"version": "0.1.3",
"version": "0.1.4",
"description": "Webpack Virtual Modules",

@@ -9,3 +9,3 @@ "main": "index.js",

"posttest": "npm run lint",
"test": "NODE_ENV=coverage nyc --check-coverage --lines 50 --branches 46 npm run tests",
"test": "NODE_ENV=coverage nyc --check-coverage --lines 100 --branches 100 npm run tests",
"tests": "mocha",

@@ -33,2 +33,3 @@ "tests:watch": "mocha -w"

"eslint": "^3.18.0",
"memory-fs": "^0.4.1",
"mocha": "^3.2.0",

@@ -39,4 +40,6 @@ "nyc": "^10.2.0",

"dependencies": {},
"files": ["*.js"],
"files": [
"*.js"
],
"greenkeeper": {}
}

@@ -24,4 +24,4 @@ ## Webpack Virtual Modules

var virtualModules = new VirtualModulesPlugin({
'node_modules/module-foo.js': 'module.exports = { foo: function() { return 'foo'; } };'
'node_modules/module-bar.js': 'module.exports = { bar: function() { return 'bar'; } };'
'node_modules/module-foo.js': 'module.exports = { foo: "foo" };'
'node_modules/module-bar.js': 'module.exports = { bar: "bar" };'
});

@@ -42,3 +42,3 @@

// Outputs 'foo'
console.log(moduleFoo.foo());
console.log(moduleFoo.foo);
```

@@ -62,14 +62,16 @@

compiler.plugin('watch', function(callback) {
virtualModules.writeModule('node_modules/module-foo.js', 'module.exports = {};');
virtualModules.writeModule('node_modules/module-foo.js', '');
callback();
});
compiler.plugin('done', function() {
virtualModules.writeModule('node_modules/module-foo.js', 'module.exports = { foo: function() { return 'foo'; } };');
// After this write the webpack will "see" that file module-foo.js has been changed and will restart compilation.
});
compiler.watch();
```
```js
// Later in some other code, perhaps in other Webpack plugin:
virtualModules.writeModule('node_modules/module-foo.js', 'module.exports = { foo: "foo" };');
// The webpack will "see" that module-foo.js changed and restart compilation
```
## Inspiration

@@ -76,0 +78,0 @@ This project is inspired by: https://github.com/rmarscher/virtual-module-webpack-plugin

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc