
Security News
The Next Open Source Security Race: Triage at Machine Speed
Claude Opus 4.6 has uncovered more than 500 open source vulnerabilities, raising new considerations for disclosure, triage, and patching at scale.
source-map-diff
Advanced tools
Compare current sourcemap to the previous to understand why it changed in size.
A powerful tool that helps you analyze JavaScript bundle size changes by comparing source maps.
# Using npm
npm install source-map-diff
# Using yarn
yarn add source-map-diff
import {
sourceMapDiff,
sourceMapDiffAsHtml,
sourceMapDiffForConsole
} from 'source-map-diff';
// Basic comparison returning structured data
async function compareBuilds() {
const result = await sourceMapDiff({
previousSrc: './dist/previous-build.js',
currentSrc: './dist/current-build.js'
});
console.log('Total files changed:', result.length);
}
// Generate HTML output
async function generateHtmlReport() {
const html = await sourceMapDiffAsHtml({
previousSrc: 'https://example.com/previous.js',
currentSrc: './dist/current.js'
});
// Write to file or insert into a webpage
console.log(html);
}
// Console output with colors
async function logToConsole() {
const output = await sourceMapDiffForConsole({
previousSrc: './dist/v1.0.0.js',
currentSrc: './dist/v1.1.0.js'
});
// Already formatted with colors for terminal display
console.log(output);
}
Returns a Promise for HTML output that can be put on a web page. Classnames are included but not styling.
import { sourceMapDiffAsHtml } from 'source-map-diff';
const html = await sourceMapDiffAsHtml({
previousSrc: './dist/bundle.v1.js',
currentSrc: './dist/bundle.v2.js'
});
Returns a Promise for color console output.
import { sourceMapDiffForConsole } from 'source-map-diff';
const consoleOutput = await sourceMapDiffForConsole({
previousSrc: 'https://mysite.com/v1/main.js',
currentSrc: 'https://mysite.com/v2/main.js'
});
console.log(consoleOutput);
Returns a Promise for structured data you can use for custom reporting:
import { sourceMapDiff } from 'source-map-diff';
// Type of the returned data
interface FileSizeComparison {
filename: string;
added: boolean; // File was not in the previous bundle
removed: boolean; // File was removed from the current bundle
isIncreased: boolean; // File grew in size
isDecreased: boolean; // File decreased in size
isSame: boolean; // File did not change size
previousSize: number; // Byte count in previous bundle
currentSize: number; // Byte count in current bundle
changeInSize: number; // Change in bytes
}
// Example usage
const result = await sourceMapDiff({
previousSrc: './old.js',
currentSrc: './new.js'
});
// Find files with the biggest increases
const increases = result
.filter(item => item.isIncreased)
.sort((a, b) => b.changeInSize - a.changeInSize);
console.table(increases);
Basic usage:
# Compare local files
npx source-map-diff --previousSrc ./dist/old.js --currentSrc ./dist/new.js
# Compare with URLs
npx source-map-diff \
--previousSrc https://mysite.com/v1/bundle.js \
--currentSrc https://mysite.com/v2/bundle.js
# HTML output (useful for reports)
npx source-map-diff --previousSrc <file> --currentSrc <file> --format html > report.html
# JSON output (useful for further processing)
npx source-map-diff --previousSrc <file> --currentSrc <file> --format json > changes.json
# Default console output with colors
npx source-map-diff --previousSrc <file> --currentSrc <file>
FAQs
Compare source maps to understand why a bundle changed in size.
The npm package source-map-diff receives a total of 5,275 weekly downloads. As such, source-map-diff popularity was classified as popular.
We found that source-map-diff demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Claude Opus 4.6 has uncovered more than 500 open source vulnerabilities, raising new considerations for disclosure, triage, and patching at scale.

Research
/Security News
Malicious dYdX client packages were published to npm and PyPI after a maintainer compromise, enabling wallet credential theft and remote code execution.

Security News
gem.coop is testing registry-level dependency cooldowns to limit exposure during the brief window when malicious gems are most likely to spread.