Socket
Book a DemoInstallSign in
Socket

@foo-software/node-modules-compare

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@foo-software/node-modules-compare

A tool to compare imported `node_modules` existence and size from one build to another

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

@foo-software/node-modules-compare

A tool to compare imported node_modules existence and size from one build to another.

Prerequisites

  • source-map-explorer is required to provide bundle data being compared. The input of this tool is the output of source-map-explorer.

Install

npm install @foo-software/node-modules-compare

Or install globally for CLI usage:

npm install -g @foo-software/node-modules-compare

Usage

Usage: Node Module

import { nodeModulesCompare } from '@foo-software/node-modules-compare';

const logNodeModulesCompareResult = async () => {
  const result = await nodeModulesCompare({
    inputFile: '/path/to/input/input-file.json',
    inputFileWithChanges: '/path/to/input/input-file-with-changes.json',
    shouldOmitNodeModuleData: true,
  });
  console.log('result', result);
};

Usage: CLI

node-modules-compare \
  --inputFile '/path/to/input/input-file.json' \
  --inputFileWithChanges '/path/to/input/input-file-with-changes.json' \
  --outputDirectory '/path/to/output'

Usage: Options

Either input or inputFile must be provided.

Option Interfaces

The interfaces below are used in various options.

interface NodeModulesCompareInputPayload {
  bundleName: string;
  files: Record<string, { size: number }>;
}

options.input

Only available in Node module

The input payload (if not using inputFile).

type input = NodeModulesCompareInputPayload[] | undefined;

options.inputFile

The input file path relative to current working directory (if not using input param).

type inputFile = string | undefined;

options.inputFileWithChanges

The input file with changes path relative to current working directory (if not using inputWithChanges param)

type inputFileWithChanges = string | undefined;

options.inputWithChanges

Only available in Node module

The input with changes payload (if not using inputFileWithChanges)

type inputWithChanges = NodeModulesCompareInputPayload[] | undefined;

options.outputDirectory

The output directory path relative to current working directory. If undefined, file will not be output.

type outputDirectory = string | undefined;

options.shouldOmitNodeModuleData

If true node module data will be ommitted from the resulting dataset.

type shouldOmitNodeModuleData = boolean | undefined;

Development

Generate Source Map Output

Below is an example of generating a source map output from a Next.js app using source-map-explorer.

source-map-explorer ./my-nextjs-app/.next/static/**/*.js \
  --json output/result.json \
  --replace 'webpack://_N_E/' --with ''

Run with npm

The npm script runs ts-node under the hood.

npm run node-modules-compare -- \
  --inputFile '/path/to/input/input-file.json' \
  --inputFileWithChanges '/path/to/input/input-file-with-changes.json' \
  --outputDirectory '/path/to/output'

FAQs

Package last updated on 05 Jul 2023

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