{"id":22021786,"url":"https://github.com/foo-software/node-modules-compare","last_synced_at":"2026-04-28T21:05:06.918Z","repository":{"id":178762432,"uuid":"655753123","full_name":"foo-software/node-modules-compare","owner":"foo-software","description":"A tool to compare imported `node_modules` existence and size from one build to another","archived":false,"fork":false,"pushed_at":"2023-07-05T23:40:48.000Z","size":733,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-07T11:47:43.211Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/foo-software.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-19T14:24:00.000Z","updated_at":"2023-12-24T13:01:35.000Z","dependencies_parsed_at":"2025-01-28T16:45:35.190Z","dependency_job_id":"1d987ce1-f988-4708-af8d-7fb5aebc411d","html_url":"https://github.com/foo-software/node-modules-compare","commit_stats":null,"previous_names":["foo-software/node-modules-compare"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foo-software%2Fnode-modules-compare","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foo-software%2Fnode-modules-compare/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foo-software%2Fnode-modules-compare/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foo-software%2Fnode-modules-compare/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/foo-software","download_url":"https://codeload.github.com/foo-software/node-modules-compare/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245085390,"owners_count":20558382,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-30T06:15:00.127Z","updated_at":"2026-04-28T21:05:06.889Z","avatar_url":"https://github.com/foo-software.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `@foo-software/node-modules-compare`\n\nA tool to compare imported `node_modules` existence and size from one build to another.\n\n## Prerequisites\n\n- [`source-map-explorer`](https://github.com/danvk/source-map-explorer) is required to provide bundle data being compared. The input of this tool is the output of `source-map-explorer`.\n\n## Install\n\n```bash\nnpm install @foo-software/node-modules-compare\n```\n\nOr install globally for CLI usage:\n\n```bash\nnpm install -g @foo-software/node-modules-compare\n```\n\n## Usage\n\n#### Usage: Node Module\n\n```typescript\nimport { nodeModulesCompare } from '@foo-software/node-modules-compare';\n\nconst logNodeModulesCompareResult = async () =\u003e {\n  const result = await nodeModulesCompare({\n    inputFile: '/path/to/input/input-file.json',\n    inputFileWithChanges: '/path/to/input/input-file-with-changes.json',\n    shouldOmitNodeModuleData: true,\n  });\n  console.log('result', result);\n};\n```\n\n#### Usage: CLI\n\n```bash\nnode-modules-compare \\\n  --inputFile '/path/to/input/input-file.json' \\\n  --inputFileWithChanges '/path/to/input/input-file-with-changes.json' \\\n  --outputDirectory '/path/to/output'\n```\n\n## API\n\n#### API: Options\n\nEither `input` or `inputFile` must be provided.\n\n**Option Interfaces**\n\nThe interfaces below are used in various options.\n\n```typescript\ninterface NodeModulesCompareInputPayload {\n  bundleName: string;\n  files: Record\u003cstring, { size: number }\u003e;\n}\n```\n\n**`options.input`**\n\n*Only available in Node module*\n\nThe input payload (if not using `inputFile`).\n\n```typescript\ntype input = NodeModulesCompareInputPayload[] | undefined;\n```\n\n**`options.inputFile`**\n\nThe input file path relative to current working directory (if not using `input` param).\n\n```typescript\ntype inputFile = string | undefined;\n```\n\n**`options.inputFileWithChanges`**\n\nThe input file with changes path relative to current working directory (if not using `inputWithChanges` param)\n\n```typescript\ntype inputFileWithChanges = string | undefined;\n```\n\n**`options.inputWithChanges`**\n\n*Only available in Node module*\n\nThe input with changes payload (if not using `inputFileWithChanges`)\n\n```typescript\ntype inputWithChanges = NodeModulesCompareInputPayload[] | undefined;\n```\n\n**`options.outputDirectory`**\n\nThe output directory path relative to current working directory. If `undefined`, file will not be output.\n\n```typescript\ntype outputDirectory = string | undefined;\n```\n\n**`options.shouldOmitNodeModuleData`**\n\nIf `true` node module data will be ommitted from the resulting dataset.\n\n```typescript\ntype shouldOmitNodeModuleData = boolean | undefined;\n```\n\n#### API: Response\n\n**Response Interfaces**\n\nThe interfaces below are used in the response interface.\n\n```typescript\nexport interface NodeModuleBundleDependent {\n  /** Bundle file or id that depends on the Node module being analyzed */\n  bundle: string;\n\n  /** The file paths or ids being used from the Node module being analyzed */\n  files: string[];\n}\n\nexport type NodeModuleBundleDependentCollection = Record\u003c\n  string,\n  NodeModuleBundleDependent\n\u003e;\n\nexport interface NodeModuleItem {\n  /** Bundles that depend on the Node module being analyzed */\n  bundleDependents: NodeModuleBundleDependentCollection;\n\n  /** The file paths or ids being used from the Node module being analyzed */\n  files: string[];\n\n  /** The package name of the Node module being analyzed */\n  packageName: string;\n\n  /** The total size in bytes of all files being used from the Node module being analyzed */\n  size: number;\n}\n\nexport type NodeModuleCollection = Record\u003cstring, NodeModuleItem\u003e;\n\nexport interface NodeModuleItemDiff {\n  /** The bundle dependents count difference between original and changed */\n  bundleDependentCount: number;\n\n  /** The number of files used from the module difference between original and changed */\n  fileCount: number;\n\n  /** The package name of the Node module being analyzed */\n  packageName: string;\n\n  /** The size in bytes difference between original and changed */\n  size: number;\n}\n\nexport interface NodeModulesDiff {\n  /** An array of data representing modules that were added */\n  added: NodeModuleItem[];\n\n  /** An array of data representing modules that changed */\n  changed: NodeModuleItemDiff[];\n\n  /** An array of data representing modules that were removed */\n  removed: NodeModuleItem[];\n\n  /** The total bytes difference between original and changed */\n  totalBytes: number;\n}\n```\n\nThe response interface.\n\n```typescript\nexport interface NodeModulesCompareResult {\n  /** The difference between original and changed modules */\n  diff?: NodeModulesDiff;\n\n  /** A collection dataset of Node modules and corresponding data */\n  nodeModules?: NodeModuleCollection;\n\n  /** A collection dataset of newer modules that may have changed and corresponding data */\n  nodeModulesWithChanges?: NodeModuleCollection;\n\n  /** File path the result is written to */\n  resultFilePath?: string;\n}\n```\n\nFor examples of the API, see the [tests](./src/nodeModulesCompare.test.ts).\n\n## Development\n\n#### Generate Source Map Output\n\nBelow is an example of generating a source map output from a Next.js app using [`source-map-explorer`](https://github.com/danvk/source-map-explorer).\n\n```bash\nsource-map-explorer ./my-nextjs-app/.next/static/**/*.js \\\n  --json output/result.json \\\n  --replace 'webpack://_N_E/' --with ''\n```\n\n#### Run with `npm`\n\nThe `npm` script runs `ts-node` under the hood.\n\n```bash\nnpm run node-modules-compare -- \\\n  --inputFile '/path/to/input/input-file.json' \\\n  --inputFileWithChanges '/path/to/input/input-file-with-changes.json' \\\n  --outputDirectory '/path/to/output'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoo-software%2Fnode-modules-compare","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffoo-software%2Fnode-modules-compare","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoo-software%2Fnode-modules-compare/lists"}