Socket
Socket
Sign inDemoInstall

webpack-virtual-modules

Package Overview
Dependencies
0
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.5.0 to 0.6.0

5

lib/index.d.ts
import type { Compiler } from 'webpack';
declare const ALL = "all";
declare const STATIC = "static";
declare const DYNAMIC = "dynamic";
declare type AvailableModules = typeof ALL | typeof STATIC | typeof DYNAMIC;
declare class VirtualModulesPlugin {

@@ -7,2 +11,3 @@ private _staticModules;

constructor(modules?: Record<string, string>);
getModuleList(filter?: AvailableModules): {};
writeModule(filePath: string, contents: string): void;

@@ -9,0 +14,0 @@ apply(compiler: Compiler): void;

@@ -8,2 +8,5 @@ "use strict";

let inode = 45000000;
const ALL = 'all';
const STATIC = 'static';
const DYNAMIC = 'dynamic';
function checkActivation(instance) {

@@ -98,2 +101,21 @@ if (!instance._compiler) {

}
getModuleList(filter = ALL) {
var _a, _b;
let modules = {};
const shouldGetStaticModules = filter === ALL || filter === STATIC;
const shouldGetDynamicModules = filter === ALL || filter === DYNAMIC;
if (shouldGetStaticModules) {
modules = Object.assign(Object.assign({}, modules), this._staticModules);
}
if (shouldGetDynamicModules) {
const finalInputFileSystem = (_a = this._compiler) === null || _a === void 0 ? void 0 : _a.inputFileSystem;
const virtualFiles = (_b = finalInputFileSystem === null || finalInputFileSystem === void 0 ? void 0 : finalInputFileSystem._virtualFiles) !== null && _b !== void 0 ? _b : {};
const dynamicModules = {};
Object.keys(virtualFiles).forEach((key) => {
dynamicModules[key] = virtualFiles[key].contents;
});
modules = Object.assign(Object.assign({}, modules), dynamicModules);
}
return modules;
}
writeModule(filePath, contents) {

@@ -100,0 +122,0 @@ if (!this._compiler) {

2

package.json
{
"name": "webpack-virtual-modules",
"version": "0.5.0",
"version": "0.6.0",
"description": "Webpack Virtual Modules",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -6,3 +6,8 @@ import path from 'path';

let inode = 45000000;
const ALL = 'all';
const STATIC = 'static';
const DYNAMIC = 'dynamic';
type AvailableModules = typeof ALL | typeof STATIC | typeof DYNAMIC;
function checkActivation(instance) {

@@ -109,2 +114,34 @@ if (!instance._compiler) {

public getModuleList(filter: AvailableModules = ALL) {
let modules = {};
const shouldGetStaticModules = filter === ALL || filter === STATIC;
const shouldGetDynamicModules = filter === ALL || filter === DYNAMIC;
if (shouldGetStaticModules) {
// Get static modules
modules = {
...modules,
...this._staticModules,
};
}
if (shouldGetDynamicModules) {
// Get dynamic modules
const finalInputFileSystem: any = this._compiler?.inputFileSystem;
const virtualFiles = finalInputFileSystem?._virtualFiles ?? {};
const dynamicModules: Record<string, string> = {};
Object.keys(virtualFiles).forEach((key: string) => {
dynamicModules[key] = virtualFiles[key].contents;
});
modules = {
...modules,
...dynamicModules,
};
}
return modules;
}
public writeModule(filePath: string, contents: string): void {

@@ -111,0 +148,0 @@ if (!this._compiler) {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc