
Weigh: Import Cost & Bundle Size
See what every import adds to your bundle, right next to it:
import { useState } from 'react'; 8.51 kB (gzip 3.26 kB)
import { marked } from 'marked'; 48.8 kB (gzip 14.9 kB)
import JSZip from 'jszip'; 98.3 kB (gzip 30.1 kB)
const charts = () => import('chart.js'); lazy 207.1 kB (gzip 71.4 kB)
Measured with react 19.3, marked 18.1, jszip 3.10 and chart.js 4.6 for the browser.
Features
- Real tree shaking.
import { debounce } from 'lodash-es' measures debounce, not the whole library.
- Minified, gzip and brotli, with download time on slow 3G and 4G.
- Fast. Measures with esbuild (shipped as WebAssembly, runs on every OS, no Node.js install needed), two packages at a time, cached per package version across restarts.
- Hover breakdown: version, license, ES module or CommonJS (with a warning when named imports can't be tree-shaken), which packages make up the size, peer dependencies left out, and lighter alternatives for heavy packages (moment, lodash, axios, uuid…).
- Every import shape:
import, export … from, require(), TypeScript import x = require(), and import() (labelled lazy). Type-only imports are skipped.
- File total in the status bar, with shared code counted once (all imports bundled together, not a naive sum).
- Reports: Show Import Sizes for This File and Measure All Dependencies (every package in
package.json, largest first).
- Re-measures automatically after
npm install.
- Colours by gzip size: small, medium, large (thresholds in settings, theme-aware).
- JavaScript, TypeScript, JSX/TSX, Vue, Svelte, Astro and MDX.
Commands
- Weigh: Show Import Sizes for This File
- Weigh: Measure All Dependencies
- Weigh: Toggle Import Sizes
- Weigh: Clear Size Cache and Measure Again
Settings
| Setting |
Default |
|
hexhad.weigh.enabled |
true |
Show sizes inline |
hexhad.weigh.display |
both |
both, gzip, minified, brotli |
hexhad.weigh.smallSize / largeSize |
10 / 50 |
Gzip kB thresholds for the colours |
hexhad.weigh.platform |
browser |
Which package entry points to measure |
hexhad.weigh.excludePeerDependencies |
true |
Leave out peers (e.g. react for react-dom) |
hexhad.weigh.showDynamicImports |
true |
Measure import() too |
hexhad.weigh.statusBar |
true |
File total in the status bar |
hexhad.weigh.maxFileSizeKB |
500 |
Skip larger files |
Colours: hexhad.weigh.small, hexhad.weigh.medium, hexhad.weigh.large, hexhad.weigh.pending in workbench.colorCustomizations.
How sizes are measured
For each import Weigh writes a one-line entry module that imports exactly what you import, bundles it with esbuild (minified, production, your chosen platform, assets left out) from your installed node_modules, then compresses the result with gzip level 9 and brotli quality 11. Package code is read, never run.
Privacy
Works offline. No telemetry, no network requests. Packages are read from your local node_modules.
MIT © 2026 HEXHAD. Third-party licenses: THIRD_PARTY_NOTICES.md.
| |