Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

module-deps

Package Overview
Dependencies
Maintainers
1
Versions
139
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

module-deps

walk the dependency graph to generate json output that can be fed into browser-pack

  • 0.5.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
949K
decreased by-17.51%
Maintainers
1
Weekly downloads
 
Created

What is module-deps?

The module-deps npm package is a tool for analyzing the dependency graph of Node.js modules. It parses the require() calls in a given entry file and recursively resolves the dependencies, providing a detailed graph of all the modules and their interconnections.

What are module-deps's main functionalities?

Dependency Graph Generation

This feature allows you to generate a JSON file that represents the dependency graph of a given entry file. The code sample demonstrates how to use module-deps to analyze 'entry.js' and output the dependency graph to 'deps.json'.

const mdeps = require('module-deps');
const JSONStream = require('JSONStream');
const fs = require('fs');

const md = mdeps();
md.pipe(JSONStream.stringify()).pipe(fs.createWriteStream('deps.json'));
md.end({ file: 'entry.js' });

Custom Resolvers

This feature allows you to provide custom resolution logic for resolving module paths. The code sample shows how to use a custom resolver function to handle module resolution.

const mdeps = require('module-deps');
const JSONStream = require('JSONStream');
const fs = require('fs');

const md = mdeps({
  resolve: (id, parent, cb) => {
    // Custom resolution logic
    cb(null, id);
  }
});
md.pipe(JSONStream.stringify()).pipe(fs.createWriteStream('deps.json'));
md.end({ file: 'entry.js' });

Transform Streams

This feature allows you to apply transform streams to the source files before they are parsed. The code sample demonstrates how to replace all instances of 'require' with 'customRequire' in the source files.

const mdeps = require('module-deps');
const through = require('through2');
const JSONStream = require('JSONStream');
const fs = require('fs');

const md = mdeps({
  transform: (file) => {
    return through(function (buf, enc, next) {
      this.push(buf.toString('utf8').replace(/require/g, 'customRequire'));
      next();
    });
  }
});
md.pipe(JSONStream.stringify()).pipe(fs.createWriteStream('deps.json'));
md.end({ file: 'entry.js' });

Other packages similar to module-deps

Keywords

FAQs

Package last updated on 21 Mar 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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