diff --git a/.gitignore b/.gitignore index 37afc83..56c4127 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts +.agentmeter.json diff --git a/README.md b/README.md index 4bb9080..fab382f 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,222 @@ # `@foo-software/node-modules-compare` -A tool to compare imported `node_modules` existence and size from one build to another +A tool to compare imported `node_modules` existence and size from one build to another. -## Development +## Prerequisites + +- [`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`. + +## Install + +```bash +npm install @foo-software/node-modules-compare +``` + +Or install globally for CLI usage: + +```bash +npm install -g @foo-software/node-modules-compare +``` + +## Usage + +#### Usage: Node Module + +```typescript +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 + +```bash +node-modules-compare \ + --inputFile '/path/to/input/input-file.json' \ + --inputFileWithChanges '/path/to/input/input-file-with-changes.json' \ + --outputDirectory '/path/to/output' +``` + +## API + +#### API: Options + +Either `input` or `inputFile` must be provided. + +**Option Interfaces** + +The interfaces below are used in various options. + +```typescript +interface NodeModulesCompareInputPayload { + bundleName: string; + files: Record; +} +``` + +**`options.input`** + +*Only available in Node module* + +The input payload (if not using `inputFile`). + +```typescript +type input = NodeModulesCompareInputPayload[] | undefined; +``` + +**`options.inputFile`** + +The input file path relative to current working directory (if not using `input` param). + +```typescript +type inputFile = string | undefined; +``` + +**`options.inputFileWithChanges`** + +The input file with changes path relative to current working directory (if not using `inputWithChanges` param) + +```typescript +type inputFileWithChanges = string | undefined; +``` + +**`options.inputWithChanges`** + +*Only available in Node module* -## Running CLI with `ts-node` +The input with changes payload (if not using `inputFileWithChanges`) + +```typescript +type inputWithChanges = NodeModulesCompareInputPayload[] | undefined; +``` + +**`options.outputDirectory`** + +The output directory path relative to current working directory. If `undefined`, file will not be output. + +```typescript +type outputDirectory = string | undefined; +``` + +**`options.shouldOmitNodeModuleData`** + +If `true` node module data will be ommitted from the resulting dataset. + +```typescript +type shouldOmitNodeModuleData = boolean | undefined; +``` + +#### API: Response + +**Response Interfaces** + +The interfaces below are used in the response interface. + +```typescript +export interface NodeModuleBundleDependent { + /** Bundle file or id that depends on the Node module being analyzed */ + bundle: string; + + /** The file paths or ids being used from the Node module being analyzed */ + files: string[]; +} + +export type NodeModuleBundleDependentCollection = Record< + string, + NodeModuleBundleDependent +>; + +export interface NodeModuleItem { + /** Bundles that depend on the Node module being analyzed */ + bundleDependents: NodeModuleBundleDependentCollection; + + /** The file paths or ids being used from the Node module being analyzed */ + files: string[]; + + /** The package name of the Node module being analyzed */ + packageName: string; + + /** The total size in bytes of all files being used from the Node module being analyzed */ + size: number; +} + +export type NodeModuleCollection = Record; + +export interface NodeModuleItemDiff { + /** The bundle dependents count difference between original and changed */ + bundleDependentCount: number; + + /** The number of files used from the module difference between original and changed */ + fileCount: number; + + /** The package name of the Node module being analyzed */ + packageName: string; + + /** The size in bytes difference between original and changed */ + size: number; +} + +export interface NodeModulesDiff { + /** An array of data representing modules that were added */ + added: NodeModuleItem[]; + + /** An array of data representing modules that changed */ + changed: NodeModuleItemDiff[]; + + /** An array of data representing modules that were removed */ + removed: NodeModuleItem[]; + + /** The total bytes difference between original and changed */ + totalBytes: number; +} +``` + +The response interface. + +```typescript +export interface NodeModulesCompareResult { + /** The difference between original and changed modules */ + diff?: NodeModulesDiff; + + /** A collection dataset of Node modules and corresponding data */ + nodeModules?: NodeModuleCollection; + + /** A collection dataset of newer modules that may have changed and corresponding data */ + nodeModulesWithChanges?: NodeModuleCollection; + + /** File path the result is written to */ + resultFilePath?: string; +} +``` + +For examples of the API, see the [tests](./src/nodeModulesCompare.test.ts). + +## Development #### Generate Source Map Output +Below 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). + ```bash -source-map-explorer ../foo/src/docker/foo-nginx/next-js/.next/static/**/*.js \ +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. + ```bash npm run node-modules-compare -- \ - --inputFile './output/result.json' \ - --inputFileWithChanges './output/result2.json' \ - --outputDirectory './output' + --inputFile '/path/to/input/input-file.json' \ + --inputFileWithChanges '/path/to/input/input-file-with-changes.json' \ + --outputDirectory '/path/to/output' ``` diff --git a/package-lock.json b/package-lock.json index 4ec9615..0710b9d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@foo-software/node-modules-compare", - "version": "0.0.1", + "version": "0.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@foo-software/node-modules-compare", - "version": "0.0.1", + "version": "0.1.1", "dependencies": { "meow": "^11.0.0" }, diff --git a/package.json b/package.json index 8454a23..0729d20 100644 --- a/package.json +++ b/package.json @@ -1,21 +1,26 @@ { "name": "@foo-software/node-modules-compare", "description": "A tool to compare imported `node_modules` existence and size from one build to another", - "version": "0.0.1", + "version": "0.1.1", + "type": "module", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", "repository": { "type": "git", "url": "git+https://github.com/foo-software/node-modules-compare.git" }, - "bin": "dist/bin/nodeModulesCompare.js", + "bin": { + "node-modules-compare": "dist/bin/nodeModulesCompare.js" + }, "scripts": { "node-modules-compare": "ts-node-esm --experimental-specifier-resolution=node src/bin/nodeModulesCompare.ts", "build": "tsc", "lint": "eslint", + "prepublishOnly": "npm run build", "prettier": "prettier --write '**/*.{ts,tsx}'", "prepare": "husky install", "test": "jest" }, - "type": "module", "lint-staged": { "**/*.{ts,tsx}": [ "eslint", diff --git a/src/bin/nodeModulesCompare.ts b/src/bin/nodeModulesCompare.ts index d4420d4..92a8eec 100644 --- a/src/bin/nodeModulesCompare.ts +++ b/src/bin/nodeModulesCompare.ts @@ -1,7 +1,7 @@ #!/usr/bin/env node import meow from 'meow'; -import getPackage from '../lib/getPackage'; -import { nodeModulesCompare } from '../nodeModulesCompare'; +import { getPackage } from '../lib/getPackage.js'; +import { nodeModulesCompare } from '../nodeModulesCompare.js'; const packageContent = await getPackage(); const packageContentParsed = JSON.parse(packageContent); @@ -9,8 +9,10 @@ const packageContentParsed = JSON.parse(packageContent); const cli = meow({ importMeta: import.meta, flags: { + h: { + type: 'boolean', + }, inputFile: { - isRequired: true, type: 'string', }, inputFileWithChanges: { @@ -26,17 +28,18 @@ const cli = meow({ }); const { + h, inputFile, inputFileWithChanges, outputDirectory, shouldOmitNodeModuleData, } = cli.flags; -console.log( - `running ${packageContentParsed.name}@${packageContentParsed.version} ✨`, -); - const runNodeModulesCompare = async () => { + console.log( + `running ${packageContentParsed.name}@${packageContentParsed.version} ✨`, + ); + const result = await nodeModulesCompare({ inputFile, inputFileWithChanges, @@ -71,4 +74,11 @@ const runNodeModulesCompare = async () => { } }; -runNodeModulesCompare(); +if (h) { + console.log( + `Please refer to GitHub for options:\n` + + ` https://github.com/foo-software/node-modules-compare/tree/main#usage-options`, + ); +} else { + runNodeModulesCompare(); +} diff --git a/src/index.ts b/src/index.ts index 07bc2b6..4cb796a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,2 +1,15 @@ -export { nodeModulesCompare as default } from './nodeModulesCompare'; -export type { ModuleCollection, ModuleItem } from './types'; +import { nodeModulesCompare } from './nodeModulesCompare.js'; + +export type { + NodeModulesCompareInputPayload, + NodeModuleBundleDependent, + NodeModuleBundleDependentCollection, + NodeModuleItem, + NodeModuleCollection, + NodeModuleItemDiff, + NodeModulesDiff, + NodeModulesCompareResult, +} from './types'; + +export { nodeModulesCompare }; +export default nodeModulesCompare; diff --git a/src/lib/createJsonFile.ts b/src/lib/createJsonFile.ts index 23373ec..07893b6 100644 --- a/src/lib/createJsonFile.ts +++ b/src/lib/createJsonFile.ts @@ -1,5 +1,5 @@ import fs from 'fs'; -import { createDirectory } from './createDirectory'; +import { createDirectory } from './createDirectory.js'; export const createJsonFile = ({ content, diff --git a/src/lib/getModules.test.ts b/src/lib/getModules.test.ts index 83e62d8..f407763 100644 --- a/src/lib/getModules.test.ts +++ b/src/lib/getModules.test.ts @@ -1,7 +1,7 @@ -import { InputResult } from '../types'; +import { NodeModulesCompareInputPayload } from '../types'; import { getModules } from './getModules'; -const mockResults: InputResult[] = [ +const mockResults: NodeModulesCompareInputPayload[] = [ { bundleName: 'chunks/abc.123.js', files: { diff --git a/src/lib/getModules.ts b/src/lib/getModules.ts index d4a4a19..c5c71fd 100644 --- a/src/lib/getModules.ts +++ b/src/lib/getModules.ts @@ -1,10 +1,13 @@ -import type { InputResult, ModuleCollection } from '../types'; +import type { + NodeModulesCompareInputPayload, + ModuleCollection, +} from '../types'; export const getModules = ({ inputResults, onlyNodeModules, }: { - inputResults: InputResult[]; + inputResults: NodeModulesCompareInputPayload[]; onlyNodeModules?: boolean; }): ModuleCollection => { const result = inputResults.reduce( diff --git a/src/lib/getNodeModules.test.ts b/src/lib/getNodeModules.test.ts new file mode 100644 index 0000000..bbef7ac --- /dev/null +++ b/src/lib/getNodeModules.test.ts @@ -0,0 +1,68 @@ +import { ModuleCollection } from '../types'; +import { getNodeModules } from './getNodeModules'; + +const modules: ModuleCollection = { + 'node_modules/prismjs/components/prism-graphql.js': { + bundleDependents: ['chunks/hij.789.js'], + file: 'node_modules/prismjs/components/prism-graphql.js', + size: 2529, + }, + 'node_modules/prismjs/components/prism-jsx.js': { + bundleDependents: ['chunks/hij.789.js'], + file: 'node_modules/prismjs/components/prism-jsx.js', + size: 2434, + }, + 'node_modules/@material-ui/core/esm/styles/colorManipulator.js': { + bundleDependents: ['chunks/efg.456.js', 'chunks/hij.789.js'], + file: 'node_modules/@material-ui/core/esm/styles/colorManipulator.js', + size: 2422, + }, +}; + +describe('getModules', () => { + it('should return a Node module collection dataset', () => { + const result = getNodeModules({ + modules, + }); + expect(result).toEqual({ + prismjs: { + bundleDependents: { + 'chunks/hij.789.js': { + bundle: 'chunks/hij.789.js', + files: [ + 'node_modules/prismjs/components/prism-graphql.js', + 'node_modules/prismjs/components/prism-jsx.js', + ], + }, + }, + files: [ + 'node_modules/prismjs/components/prism-graphql.js', + 'node_modules/prismjs/components/prism-jsx.js', + ], + packageName: 'prismjs', + size: 4963, + }, + '@material-ui/core': { + bundleDependents: { + 'chunks/efg.456.js': { + bundle: 'chunks/efg.456.js', + files: [ + 'node_modules/@material-ui/core/esm/styles/colorManipulator.js', + ], + }, + 'chunks/hij.789.js': { + bundle: 'chunks/hij.789.js', + files: [ + 'node_modules/@material-ui/core/esm/styles/colorManipulator.js', + ], + }, + }, + files: [ + 'node_modules/@material-ui/core/esm/styles/colorManipulator.js', + ], + packageName: '@material-ui/core', + size: 2422, + }, + }); + }); +}); diff --git a/src/lib/getNodeModules.ts b/src/lib/getNodeModules.ts index a410927..d8c5b9a 100644 --- a/src/lib/getNodeModules.ts +++ b/src/lib/getNodeModules.ts @@ -3,7 +3,7 @@ import type { NodeModuleCollection, ModuleCollection, } from '../types'; -import { getNodeModulePackageName } from './getNodeModulePackageName'; +import { getNodeModulePackageName } from './getNodeModulePackageName.js'; const getBundleDependents = ({ bundles, diff --git a/src/lib/getPackage.ts b/src/lib/getPackage.ts index 37c6aa4..0f60f91 100644 --- a/src/lib/getPackage.ts +++ b/src/lib/getPackage.ts @@ -1,11 +1,9 @@ import fs from 'node:fs/promises'; import { fileURLToPath } from 'node:url'; -const getPackage = (): Promise => { +export const getPackage = (): Promise => { const filePath = fileURLToPath( new URL('../../package.json', import.meta.url), ); return fs.readFile(filePath, 'utf8'); }; - -export default getPackage; diff --git a/src/nodeModulesCompare.test.ts b/src/nodeModulesCompare.test.ts new file mode 100644 index 0000000..0791a9e --- /dev/null +++ b/src/nodeModulesCompare.test.ts @@ -0,0 +1,268 @@ +import { nodeModulesCompare } from './nodeModulesCompare'; +import { NodeModulesCompareInputPayload } from './types'; + +const mockInputBase: NodeModulesCompareInputPayload[] = [ + { + bundleName: './dist/chunks/abc.js', + files: { + 'node_modules/react-dom/index.js': { + size: 227, + }, + 'node_modules/react/cjs/react.production.min.js': { + size: 5946, + }, + 'node_modules/react-dom/cjs/react-dom.production.min.js': { + size: 118677, + }, + 'node_modules/prismjs/components/prism-bash.js': { + size: 5912, + }, + 'node_modules/prismjs/components/prism-core.js': { + size: 7269, + }, + 'node_modules/prismjs/components/prism-tsx.js': { + size: 239, + }, + 'node_modules/prismjs/components/prism-clike.js': { + size: 712, + }, + '[sourceMappingURL]': { + size: 57, + }, + '[unmapped]': { + size: 99, + }, + '[EOLs]': { + size: 1, + }, + }, + }, +]; + +const mockInputBase2: NodeModulesCompareInputPayload[] = [ + ...mockInputBase, + { + bundleName: './dist/chunks/def.js', + files: { + 'node_modules/foo/index.js': { + size: 100, + }, + 'node_modules/react-dom/index.js': { + size: 227, + }, + 'node_modules/react-dom/cjs/react-dom.production.min.js': { + size: 118677, + }, + }, + }, +]; + +const mockInputBase3: NodeModulesCompareInputPayload[] = [ + ...mockInputBase2, + { + bundleName: './dist/chunks/def.js', + files: { + 'node_modules/abc/index.js': { + size: 200, + }, + }, + }, +]; + +const mockInput: NodeModulesCompareInputPayload[] = [ + ...mockInputBase3, + { + bundleName: './dist/chunks/hij.js', + files: { + 'node_modules/abc/index.js': { + size: 200, + }, + }, + }, +]; + +const mockResult = { + 'react-dom': { + bundleDependents: { + './dist/chunks/abc.js': { + bundle: './dist/chunks/abc.js', + files: [ + 'node_modules/react-dom/cjs/react-dom.production.min.js', + 'node_modules/react-dom/index.js', + ], + }, + './dist/chunks/def.js': { + bundle: './dist/chunks/def.js', + files: [ + 'node_modules/react-dom/cjs/react-dom.production.min.js', + 'node_modules/react-dom/index.js', + ], + }, + }, + files: [ + 'node_modules/react-dom/cjs/react-dom.production.min.js', + 'node_modules/react-dom/index.js', + ], + packageName: 'react-dom', + size: 118904, + }, + prismjs: { + bundleDependents: { + './dist/chunks/abc.js': { + bundle: './dist/chunks/abc.js', + files: [ + 'node_modules/prismjs/components/prism-core.js', + 'node_modules/prismjs/components/prism-bash.js', + 'node_modules/prismjs/components/prism-clike.js', + 'node_modules/prismjs/components/prism-tsx.js', + ], + }, + }, + files: [ + 'node_modules/prismjs/components/prism-core.js', + 'node_modules/prismjs/components/prism-bash.js', + 'node_modules/prismjs/components/prism-clike.js', + 'node_modules/prismjs/components/prism-tsx.js', + ], + packageName: 'prismjs', + size: 14132, + }, + react: { + bundleDependents: { + './dist/chunks/abc.js': { + bundle: './dist/chunks/abc.js', + files: ['node_modules/react/cjs/react.production.min.js'], + }, + }, + files: ['node_modules/react/cjs/react.production.min.js'], + packageName: 'react', + size: 5946, + }, + abc: { + bundleDependents: { + './dist/chunks/def.js': { + bundle: './dist/chunks/def.js', + files: ['node_modules/abc/index.js'], + }, + './dist/chunks/hij.js': { + bundle: './dist/chunks/hij.js', + files: ['node_modules/abc/index.js'], + }, + }, + files: ['node_modules/abc/index.js'], + packageName: 'abc', + size: 200, + }, + foo: { + bundleDependents: { + './dist/chunks/def.js': { + bundle: './dist/chunks/def.js', + files: ['node_modules/foo/index.js'], + }, + }, + files: ['node_modules/foo/index.js'], + packageName: 'foo', + size: 100, + }, +}; + +describe('nodeModulesCompare', () => { + it('should return a Node module compare result ', async () => { + const result = await nodeModulesCompare({ + input: mockInput, + inputWithChanges: [ + ...mockInputBase, + { + bundleName: './dist/chunks/def.js', + files: { + 'node_modules/foo/index.js': { + size: 100, + }, + 'node_modules/foo/some-other-module.js': { + size: 100, + }, + 'node_modules/react-dom/index.js': { + size: 227, + }, + 'node_modules/react-dom/cjs/react-dom.production.min.js': { + size: 118677, + }, + }, + }, + { + bundleName: './dist/chunks/hij.js', + files: { + 'node_modules/abc/index.js': { + size: 200, + }, + 'node_modules/react-dom/index.js': { + size: 227, + }, + }, + }, + { + bundleName: './dist/chunks/klm.js', + files: { + 'node_modules/foo/index.js': { + size: 100, + }, + 'node_modules/hi/index.js': { + size: 100, + }, + }, + }, + ], + shouldOmitNodeModuleData: true, + }); + expect(result).toEqual({ + diff: { + added: [ + { + bundleDependents: { + './dist/chunks/klm.js': { + bundle: './dist/chunks/klm.js', + files: ['node_modules/hi/index.js'], + }, + }, + files: ['node_modules/hi/index.js'], + packageName: 'hi', + size: 100, + }, + ], + changed: [ + { + bundleDependentCount: 1, + fileCount: 0, + packageName: 'react-dom', + size: 0, + }, + { + bundleDependentCount: -1, + fileCount: 0, + packageName: 'abc', + size: 0, + }, + { + bundleDependentCount: 0, + fileCount: 1, + packageName: 'foo', + size: 100, + }, + ], + removed: [], + totalBytes: 200, + }, + }); + }); + + it('should return a Node module compare result without a diff when there is no difference', async () => { + const result = await nodeModulesCompare({ + input: mockInput, + inputWithChanges: mockInput, + }); + expect(result).toEqual({ + nodeModules: mockResult, + nodeModulesWithChanges: mockResult, + }); + }); +}); diff --git a/src/nodeModulesCompare.ts b/src/nodeModulesCompare.ts index 846a9a1..4c33298 100644 --- a/src/nodeModulesCompare.ts +++ b/src/nodeModulesCompare.ts @@ -1,37 +1,64 @@ import path from 'path'; -import { createJsonFile } from './lib/createJsonFile'; -import { getInputFileContent } from './lib/getInputFileContent'; -import { getModules } from './lib/getModules'; -import { getNodeModuleCollectionDiff } from './lib/getNodeModuleCollectionDiff'; -import { getNodeModules } from './lib/getNodeModules'; -import type { NodeModuleCollection, NodeModulesCompareResult } from './types'; +import { createJsonFile } from './lib/createJsonFile.js'; +import { getInputFileContent } from './lib/getInputFileContent.js'; +import { getModules } from './lib/getModules.js'; +import { getNodeModuleCollectionDiff } from './lib/getNodeModuleCollectionDiff.js'; +import { getNodeModules } from './lib/getNodeModules.js'; +import type { + NodeModulesCompareInputPayload, + NodeModuleCollection, + NodeModulesCompareResult, +} from './types'; export const nodeModulesCompare = async ({ + input, inputFile, inputFileWithChanges, + inputWithChanges, outputDirectory, shouldOmitNodeModuleData, }: { - /** The input file path relative to current working directory */ - inputFile: string; + /** The input payload (if not using `inputFile`) */ + input?: NodeModulesCompareInputPayload[]; - /** The input file with changes path relative to current working directory */ + /** The input file path relative to current working directory (if not using `input` param) */ + inputFile?: string; + + /** The input file with changes path relative to current working directory (if not using `inputWithChanges` param) */ inputFileWithChanges?: string; - /** The output directory path relative to current working directory */ + /** The input with changes payload (if not using `inputFileWithChanges`) */ + inputWithChanges?: NodeModulesCompareInputPayload[]; + + /** The output directory path relative to current working directory. If `undefined`, file will not be output */ outputDirectory?: string; /** If `true` node module data will be ommitted from the resulting dataset */ shouldOmitNodeModuleData?: boolean; }): Promise => { + // validate input + if (!input && !inputFile) { + throw new Error('Either `input` or `inputFile` must be provided'); + } + const currentWorkingDirectoryPath = process.cwd(); - const inputFileJsonContent = await getInputFileContent({ - inputFile, - }); + let inputResults: NodeModulesCompareInputPayload[] | undefined = input; + if (!inputResults && inputFile) { + const inputFileJsonContent = await getInputFileContent({ + inputFile, + }); + inputResults = inputFileJsonContent.results; + } + + if (!inputResults) { + throw new Error( + `There was a problem finding the input. Check that the input or input file is formatted correctly`, + ); + } const modules = getModules({ - inputResults: inputFileJsonContent.results, + inputResults, onlyNodeModules: true, }); const nodeModules = getNodeModules({ @@ -39,17 +66,24 @@ export const nodeModulesCompare = async ({ }); let nodeModulesWithChanges: NodeModuleCollection | undefined; - if (inputFileWithChanges) { - const inputFileJsonContentWithChanges = await getInputFileContent({ - inputFile: inputFileWithChanges, - }); - const modulesWithChanges = getModules({ - inputResults: inputFileJsonContentWithChanges.results, - onlyNodeModules: true, - }); - nodeModulesWithChanges = getNodeModules({ - modules: modulesWithChanges, - }); + if (inputWithChanges || inputFileWithChanges) { + let inputResultsWithChanges: NodeModulesCompareInputPayload[] | undefined = + inputWithChanges; + if (!inputResultsWithChanges && inputFileWithChanges) { + const inputFileJsonContentWithChanges = await getInputFileContent({ + inputFile: inputFileWithChanges, + }); + inputResultsWithChanges = inputFileJsonContentWithChanges.results; + } + if (inputResultsWithChanges) { + const modulesWithChanges = getModules({ + inputResults: inputResultsWithChanges, + onlyNodeModules: true, + }); + nodeModulesWithChanges = getNodeModules({ + modules: modulesWithChanges, + }); + } } const result: NodeModulesCompareResult = { diff --git a/src/types.ts b/src/types.ts index 9563e64..9c76a9b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,10 +1,10 @@ -export interface InputResult { +export interface NodeModulesCompareInputPayload { bundleName: string; files: Record; } export interface InputFileContent { - results: InputResult[]; + results: NodeModulesCompareInputPayload[]; } export interface ModuleItem {