Source maps in npm packages

A .map file can hold the full original source of every file that went into the bundle. If it's in the tarball, anyone who runs npm pack on your package has it.

1. What's actually in a .map

{
  "version": 3,
  "sources": ["../src/client.ts", "../src/auth.ts"],
  "sourcesContent": ["import ... // full original file", "..."],
  "mappings": "AAAA,SAAS..."
}

sources leaks file names and layout. sourcesContent is the actual pre-build code, comments, internal URLs and TODOs included. Without sourcesContent a map is mostly noise; with it, minification undid nothing.

2. How common it is

Of the 331 popular packages we scanned, 152 (46%) publish .map files and 99 (30%) inline sourcesContent. For open-source packages that's just weight. For a closed-source SDK, CLI or paid library it's the codebase. Full numbers: npm tarball audit 2026.

3. Check a tarball in 30 seconds

# your package, before publishing
npm pack
# or anything already on the registry
npm pack some-package@latest

mkdir t && tar -xzf *.tgz -C t
find t -name '*.map' | while read f; do
  jq -r --arg f "$f" '(.sourcesContent // []) | map(select(. != null)) | length
    | if . > 0 then "\($f): \(.) files of source inlined" else empty end' "$f"
done

No output means no inlined source. Maps without sourcesContent still expose paths; decide if you need them at all.

4. Turn it off where it's made

ToolDefaultFix
tscno source unless inlineSourcesdrop "inlineSources": true, or "sourceMap": false in the publish tsconfig
esbuildincludes sourcesourcesContent: false (CLI: --sources-content=false)
Rollupincludes sourceoutput.sourcemapExcludeSources: true
Viteno maps unless build.sourcemap is setleave build.sourcemap off for the published build
webpackdevtool: false in production modeif you need maps: devtool: "nosources-source-map"

5. Or keep them out of the tarball

If you want maps for your own error tracker, upload them there and exclude them from the package. With a files allowlist, ignore files can't remove anything it includes, so negate inside the array:

"files": ["dist", "!dist/**/*.map"]

Using .npmignore instead? Read the .npmignore trap first: it replaces .gitignore, so dist/*.map in .gitignore stops applying the moment you add one.

Why your git scanner says nothing

Maps are build output. They're gitignored, never committed, and written to disk right before npm publish. Push protection and history scanners only see commits. The tarball is the only place to look.

Packages that currently inline source

Open-source packages, so nothing secret; shown as real examples of the default.

Check yours

Scan any published package or upload a tarball, free, no login. It flags maps, inlined source, secrets and stray files in everything that would ship. Or fail the publish in CI when a new one appears.