<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Line Answered</title>
    <description>The latest articles on DEV Community by Line Answered (@lineanswered).</description>
    <link>https://dev.to/lineanswered</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4258057%2F851a4d44-f3f2-4ff3-a8ce-da28b5d0d3db.png</url>
      <title>DEV Community: Line Answered</title>
      <link>https://dev.to/lineanswered</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lineanswered"/>
    <language>en</language>
    <item>
      <title>Your npm package's source maps may be shipping your whole codebase</title>
      <dc:creator>Line Answered</dc:creator>
      <pubDate>Mon, 23 Nov 2026 00:29:59 +0000</pubDate>
      <link>https://dev.to/lineanswered/your-npm-packages-source-maps-may-be-shipping-your-whole-codebase-5hem</link>
      <guid>https://dev.to/lineanswered/your-npm-packages-source-maps-may-be-shipping-your-whole-codebase-5hem</guid>
      <description>&lt;p&gt;A &lt;code&gt;.map&lt;/code&gt; file can hold the full original source of every file that went into the bundle. If it's in the tarball, anyone who runs &lt;code&gt;npm pack&lt;/code&gt; on your package has it.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://releaseshield.lineanswered.com/guides/source-maps-npm?ref=devto" rel="noopener noreferrer"&gt;ReleaseShield&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  1. What's actually in a .map
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"sources"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"../src/client.ts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"../src/auth.ts"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"sourcesContent"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"import ... // full original file"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"..."&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"mappings"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"AAAA,SAAS..."&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;h2&gt;
  
  
  2. How common it is
&lt;/h2&gt;

&lt;p&gt;Of the 500 popular packages we scanned, 284 (57%) publish &lt;code&gt;.map&lt;/code&gt; files and 195 (39%) inline &lt;code&gt;sourcesContent&lt;/code&gt;. For open-source packages that's just weight. For a closed-source SDK, CLI or paid library it's the codebase. Full numbers: &lt;a href="https://releaseshield.lineanswered.com/guides/source-maps-npm?ref=devto" rel="noopener noreferrer"&gt;npm tarball audit 2026&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Check a tarball in 30 seconds
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# your package, before publishing&lt;/span&gt;
npm pack

&lt;span class="c"&gt;# or anything already on the registry&lt;/span&gt;
npm pack some-package@latest

mkdir t &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; tar -xzf *.tgz -C t
find t -name &lt;span class="s1"&gt;'*.map'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="nb"&gt;read&lt;/span&gt; f&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  jq -r --arg f &lt;span class="s2"&gt;"$f"&lt;/span&gt; &lt;span class="s1"&gt;'(.sourcesContent // []) | map(select(. != null)) | length
    | if . &amp;gt; 0 then "\($f): \(.) files of source inlined" else empty end'&lt;/span&gt; &lt;span class="s2"&gt;"$f"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No output means no inlined source. Maps without &lt;code&gt;sourcesContent&lt;/code&gt; still expose paths; decide if you need them at all.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Turn it off where it's made
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Default&lt;/th&gt;
&lt;th&gt;Fix&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;tsc&lt;/td&gt;
&lt;td&gt;no source unless &lt;code&gt;inlineSources&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;drop &lt;code&gt;"inlineSources": true&lt;/code&gt;, or &lt;code&gt;"sourceMap": false&lt;/code&gt; in the publish tsconfig&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;esbuild&lt;/td&gt;
&lt;td&gt;includes source&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;sourcesContent: false&lt;/code&gt; (CLI: &lt;code&gt;--sources-content=false&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rollup&lt;/td&gt;
&lt;td&gt;includes source&lt;/td&gt;
&lt;td&gt;&lt;code&gt;output.sourcemapExcludeSources: true&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Vite&lt;/td&gt;
&lt;td&gt;no maps unless &lt;code&gt;build.sourcemap&lt;/code&gt; is set&lt;/td&gt;
&lt;td&gt;leave &lt;code&gt;build.sourcemap&lt;/code&gt; off for the published build&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;webpack&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;devtool: false&lt;/code&gt; in production mode&lt;/td&gt;
&lt;td&gt;if you need maps: &lt;code&gt;devtool: "nosources-source-map"&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  5. Or keep them out of the tarball
&lt;/h2&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"files"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"dist"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"!dist/**/*.map"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using &lt;code&gt;.npmignore&lt;/code&gt; instead? Read &lt;a href="https://releaseshield.lineanswered.com/guides/npmignore-trap?ref=devto" rel="noopener noreferrer"&gt;the .npmignore trap&lt;/a&gt; first: it replaces &lt;code&gt;.gitignore&lt;/code&gt;, so &lt;code&gt;dist/*.map&lt;/code&gt; in &lt;code&gt;.gitignore&lt;/code&gt; stops applying the moment you add one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why your git scanner says nothing
&lt;/h2&gt;

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




&lt;p&gt;&lt;em&gt;Check any published package before you ship it: &lt;a href="https://releaseshield.lineanswered.com/?ref=devto#check" rel="noopener noreferrer"&gt;scan a package or upload a tarball, free&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>npm</category>
      <category>security</category>
      <category>node</category>
    </item>
    <item>
      <title>Published a .env or API key to npm? What to do, in order</title>
      <dc:creator>Line Answered</dc:creator>
      <pubDate>Sun, 22 Nov 2026 18:30:00 +0000</pubDate>
      <link>https://dev.to/lineanswered/published-a-env-or-api-key-to-npm-what-to-do-in-order-4dec</link>
      <guid>https://dev.to/lineanswered/published-a-env-or-api-key-to-npm-what-to-do-in-order-4dec</guid>
      <description>&lt;p&gt;A &lt;code&gt;.env&lt;/code&gt;, an &lt;code&gt;.npmrc&lt;/code&gt; with a token, a private key, or a key baked into &lt;code&gt;dist/&lt;/code&gt; went out with &lt;code&gt;npm publish&lt;/code&gt;. Here's the order that matters.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://releaseshield.lineanswered.com/guides/leaked-secret-npm-publish?ref=devto" rel="noopener noreferrer"&gt;ReleaseShield&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Rotate the credential now
&lt;/h2&gt;

&lt;p&gt;Assume it's already copied. Registry mirrors and CDNs (unpkg, jsDelivr, npmmirror) fetch new tarballs within minutes, and people do scrape new releases for keys. Unpublishing doesn't un-leak anything, so revoke and reissue before you touch npm:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;npm token: &lt;code&gt;npm token list&lt;/code&gt;, then &lt;code&gt;npm token revoke &amp;lt;id&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;GitHub token: Settings → Developer settings → revoke it, then check the audit log&lt;/li&gt;
&lt;li&gt;AWS key: deactivate and delete it in IAM, then check CloudTrail for calls you didn't make&lt;/li&gt;
&lt;li&gt;Stripe, OpenAI, database URLs, webhook secrets: roll them in the provider dashboard&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once the old value is dead, the rest is cleanup.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Find every version that has it
&lt;/h2&gt;

&lt;p&gt;The file is rarely in just the latest release. Check every published version — pull each tarball from the registry and look for the filename, or for the leaked value itself:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;pkg&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;your-package
&lt;span class="nv"&gt;needle&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'\.env'&lt;/span&gt;          &lt;span class="c"&gt;# filename regex, e.g. '\.env|\.npmrc|id_rsa'&lt;/span&gt;
&lt;span class="nv"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'sk_live_abc123'&lt;/span&gt;  &lt;span class="c"&gt;# or the leaked value itself (optional)&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; v &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;$(&lt;/span&gt;npm view &lt;span class="s2"&gt;"$pkg"&lt;/span&gt; versions --json &lt;span class="o"&gt;|&lt;/span&gt; jq -r &lt;span class="s1"&gt;'if type=="array" then .[] else . end'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nv"&gt;tgz&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$(&lt;/span&gt;npm pack &lt;span class="s2"&gt;"$pkg@$v"&lt;/span&gt; --silent 2&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;continue&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; tar -tzf &lt;span class="s2"&gt;"$tgz"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; grep -qE &lt;span class="s2"&gt;"(^|/)($needle)"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"$v: file"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;fi&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; -n &lt;span class="s2"&gt;"$value"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; tar -xzOf &lt;span class="s2"&gt;"$tgz"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; grep -qF &lt;span class="s2"&gt;"$value"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"$v: value"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;fi&lt;/span&gt;
  rm -f &lt;span class="s2"&gt;"$tgz"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Filename matching misses keys that a build step inlined into a bundle (for example &lt;code&gt;process.env.X&lt;/code&gt; replaced at build time). Grepping for the value catches that, but only if you know the value. To find secrets you don't know about, &lt;a href="https://releaseshield.lineanswered.com/?ref=devto#check" rel="noopener noreferrer"&gt;scan the published package&lt;/a&gt; — it reads every file in the tarball, not just the names.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Unpublish, if npm will let you
&lt;/h2&gt;

&lt;p&gt;npm's unpublish policy is strict. You can remove a version yourself only if it was published less than 72 hours ago, &lt;strong&gt;or&lt;/strong&gt; no other public package depends on it, it had fewer than 300 downloads in the last week, and it has a single owner/maintainer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm unpublish your-package@1.4.2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can never reuse that version number. If you unpublish every version, the name is blocked for 24 hours. When the policy says no, npm support can still remove a version that contains a secret — open a ticket at npmjs.com/support with the package, versions and what leaked. Rotate first anyway: removal can take days.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Ship a clean patch and deprecate the bad range
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# fix packaging (step 5), then&lt;/span&gt;
npm version patch &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; npm publish

&lt;span class="c"&gt;# warn anyone still installing a leaky version&lt;/span&gt;
npm deprecate &lt;span class="s2"&gt;"your-package@&amp;lt;1.4.3"&lt;/span&gt; &lt;span class="s2"&gt;"contained a leaked credential (rotated); upgrade to 1.4.3+"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A deprecated version stays installable, but npm prints a warning on every install. Most people pin with &lt;code&gt;^&lt;/code&gt;, so they pick up the patch on their next install anyway.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Fix why it shipped
&lt;/h2&gt;

&lt;p&gt;Almost always one of these:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;code&gt;.npmignore&lt;/code&gt; exists, so npm stopped reading &lt;code&gt;.gitignore&lt;/code&gt; and your gitignored &lt;code&gt;.env&lt;/code&gt; was back in scope. Details: &lt;a href="https://releaseshield.lineanswered.com/guides/npmignore-trap?ref=devto" rel="noopener noreferrer"&gt;the .npmignore trap&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;"files": ["dist"]&lt;/code&gt; and something wrote a secret or source map into &lt;code&gt;dist/&lt;/code&gt;. The &lt;code&gt;files&lt;/code&gt; allowlist beats both ignore files. See &lt;a href="https://releaseshield.lineanswered.com/guides/source-maps-npm?ref=devto" rel="noopener noreferrer"&gt;source maps in npm packages&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Publishing from a laptop or a CI workspace with leftovers. npm packs the working directory, not the git commit, so files that were never committed still ship.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Switch to a &lt;code&gt;"files"&lt;/code&gt; allowlist, then check the result before every publish with &lt;code&gt;npm pack --dry-run&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Make the next one fail in CI
&lt;/h2&gt;

&lt;p&gt;A dry-run list only helps if someone reads it. Gate the publish job instead — &lt;a href="https://releaseshield.lineanswered.com/?ref=devto" rel="noopener noreferrer"&gt;ReleaseShield&lt;/a&gt; runs &lt;code&gt;npm pack&lt;/code&gt;, unpacks the tarball and fails the step on secrets or sensitive files before &lt;code&gt;npm publish&lt;/code&gt; runs. The GitHub Action setup is in &lt;a href="https://releaseshield.lineanswered.com/docs?ref=devto" rel="noopener noreferrer"&gt;the docs&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Check any published package before you ship it: &lt;a href="https://releaseshield.lineanswered.com/?ref=devto#check" rel="noopener noreferrer"&gt;scan a package or upload a tarball, free&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>npm</category>
      <category>security</category>
      <category>node</category>
    </item>
    <item>
      <title>The .npmignore trap: why npm publish ships files your .gitignore hides</title>
      <dc:creator>Line Answered</dc:creator>
      <pubDate>Sun, 22 Nov 2026 15:33:47 +0000</pubDate>
      <link>https://dev.to/lineanswered/the-npmignore-trap-why-npm-publish-ships-files-your-gitignore-hides-4l5f</link>
      <guid>https://dev.to/lineanswered/the-npmignore-trap-why-npm-publish-ships-files-your-gitignore-hides-4l5f</guid>
      <description>&lt;p&gt;Adding a &lt;code&gt;.npmignore&lt;/code&gt; makes npm stop reading &lt;code&gt;.gitignore&lt;/code&gt; — so &lt;code&gt;.env&lt;/code&gt; files, source maps, and build leftovers end up in the tarball. Git secret scanning never sees them.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://releaseshield.lineanswered.com/guides/npmignore-trap?ref=devto" rel="noopener noreferrer"&gt;ReleaseShield&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  1. A &lt;code&gt;.npmignore&lt;/code&gt; replaces &lt;code&gt;.gitignore&lt;/code&gt;, it doesn't extend it
&lt;/h2&gt;

&lt;p&gt;With no &lt;code&gt;.npmignore&lt;/code&gt;, npm uses your &lt;code&gt;.gitignore&lt;/code&gt; to decide what to leave out. The moment you add a &lt;code&gt;.npmignore&lt;/code&gt; (usually to drop &lt;code&gt;src/&lt;/code&gt; or &lt;code&gt;test/&lt;/code&gt;), npm stops reading &lt;code&gt;.gitignore&lt;/code&gt; for that directory. Everything git was hiding is back in scope.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# .gitignore
node_modules
.env
dist/*.map
coverage/

# .npmignore  (added later "to make the package smaller")
src/
test/

# result: .env, dist/*.map and coverage/ are now in the tarball
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. npm packs the working directory, not the commit
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;npm pack&lt;/code&gt; and &lt;code&gt;npm publish&lt;/code&gt; read files from disk. Gitignored files exist on disk: the &lt;code&gt;.env&lt;/code&gt; on your laptop, the source maps your bundler just wrote to &lt;code&gt;dist/&lt;/code&gt;, the coverage report from the test step that ran before publish in CI. None of them were ever committed, so push protection, gitleaks, or any scanner that walks git history has nothing to look at. The tarball is a separate artifact and nobody inspects it.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. &lt;code&gt;"files"&lt;/code&gt; wins over both ignore files
&lt;/h2&gt;

&lt;p&gt;A &lt;code&gt;"files"&lt;/code&gt; array in &lt;code&gt;package.json&lt;/code&gt; is an allowlist and is the safer default. But a root &lt;code&gt;.npmignore&lt;/code&gt; or &lt;code&gt;.gitignore&lt;/code&gt; can't exclude anything it includes. &lt;code&gt;"files": ["dist"]&lt;/code&gt; ships every file in &lt;code&gt;dist/&lt;/code&gt;, including &lt;code&gt;*.map&lt;/code&gt;, dotfiles like &lt;code&gt;dist/.env&lt;/code&gt;, and anything else a build step dropped there. Negate inside the array if you need to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"files"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"dist"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"!dist/**/*.map"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Source maps carry your source
&lt;/h2&gt;

&lt;p&gt;Most bundlers write &lt;code&gt;sourcesContent&lt;/code&gt; into maps by default (esbuild does; TypeScript does with &lt;code&gt;inlineSources&lt;/code&gt;). That field holds the full pre-build source of every input file. For an open-source package it's dead weight. For a closed-source SDK or CLI it's the codebase, comments included. In our &lt;a href="https://releaseshield.lineanswered.com/report/npm-tarball-audit-2026?ref=devto" rel="noopener noreferrer"&gt;audit of 445 popular packages&lt;/a&gt;, 56% ship source maps — and a meaningful fraction inline the source.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Check before you publish
&lt;/h2&gt;

&lt;p&gt;List exactly what would ship, without publishing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm pack --dry-run --json &lt;span class="o"&gt;|&lt;/span&gt; jq -r &lt;span class="s1"&gt;'.[0].files[].path'&lt;/span&gt;

&lt;span class="c"&gt;# quick grep for the usual suspects&lt;/span&gt;
npm pack --dry-run --json &lt;span class="o"&gt;|&lt;/span&gt; jq -r &lt;span class="s1"&gt;'.[0].files[].path'&lt;/span&gt; \
  &lt;span class="o"&gt;|&lt;/span&gt; grep -E &lt;span class="s1"&gt;'(^|/)\.env|\.map$|\.pem$|id_rsa|\.npmrc|coverage/|\.sqlite'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That catches filenames. It won't catch a Stripe key pasted into a fixture or a token baked into &lt;code&gt;dist/&lt;/code&gt; by a build-time env var. For that you have to read file contents — which is what &lt;a href="https://releaseshield.lineanswered.com/?ref=devto" rel="noopener noreferrer"&gt;ReleaseShield&lt;/a&gt; does: it unpacks the tarball and runs secret patterns and sensitive-file rules over every byte that would ship. Free, no login.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix order if something leaked
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Rotate the credential first.&lt;/strong&gt; Unpublishing doesn't help: mirrors and caches already have the tarball.&lt;/li&gt;
&lt;li&gt;Switch to a &lt;code&gt;"files"&lt;/code&gt; allowlist, or put every &lt;code&gt;.gitignore&lt;/code&gt; line you still need into &lt;code&gt;.npmignore&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Publish a patch version and deprecate the leaky one with &lt;code&gt;npm deprecate&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Add the dry-run check (or a scanner) to the publish job so it fails before it ships next time.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The full walkthrough, including how to find every affected version and npm's unpublish limits, is in the companion guide: &lt;a href="https://releaseshield.lineanswered.com/guides/leaked-secret-npm-publish?ref=devto" rel="noopener noreferrer"&gt;published a secret to npm&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Check any published package before you ship it: &lt;a href="https://releaseshield.lineanswered.com/?ref=devto#check" rel="noopener noreferrer"&gt;scan a package or upload a tarball, free&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>npm</category>
      <category>security</category>
      <category>node</category>
    </item>
    <item>
      <title>We unpacked 445 popular npm packages. 39% of them ship their full original source.</title>
      <dc:creator>Line Answered</dc:creator>
      <pubDate>Sat, 21 Nov 2026 23:15:15 +0000</pubDate>
      <link>https://dev.to/lineanswered/we-unpacked-445-popular-npm-packages-39-of-them-ship-their-full-original-source-48h9</link>
      <guid>https://dev.to/lineanswered/we-unpacked-445-popular-npm-packages-39-of-them-ship-their-full-original-source-48h9</guid>
      <description>&lt;p&gt;Your git repo is not what your users install. &lt;code&gt;npm publish&lt;/code&gt; ships whatever &lt;code&gt;npm pack&lt;/code&gt; puts in the tarball, and that decision is made by build output, a &lt;code&gt;files&lt;/code&gt; field, and ignore files — not by what you committed. We downloaded the latest published tarball of 445 npm packages — the exact bytes &lt;code&gt;npm install&lt;/code&gt; fetches — and inspected every file inside. Here is what is actually in there.&lt;/p&gt;

&lt;h2&gt;
  
  
  The numbers
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;56% ship source maps.&lt;/strong&gt; 247 of 445 packages publish &lt;code&gt;.map&lt;/code&gt; files — roughly 32,000 map files in total.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;39% embed the full original source.&lt;/strong&gt; 173 packages inline &lt;code&gt;sourcesContent&lt;/code&gt; in their maps, which means the complete pre-build source — comments, internal file names and all — can be reconstructed from the tarball.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;35% are over 1 MB unpacked.&lt;/strong&gt; 157 packages exceed 1 MB and 32 exceed 10 MB. The median is 422.4 KB. The largest tarball in the set is 94.4 MB.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;5% matched a secret pattern or sensitive-file rule.&lt;/strong&gt; 21 packages. We don't publish which ones or what matched — some are test fixtures, and the rest belong with the maintainer, not in an article.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;42% had nothing flagged at all.&lt;/strong&gt; A clean tarball is entirely achievable. More on who manages it below.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Smaller counts, same story: 3 packages shipped CI configuration, 2 shipped editor configuration, and 2 shipped test-coverage output.&lt;/p&gt;

&lt;h2&gt;
  
  
  How we looked (and why git doesn't tell you this)
&lt;/h2&gt;

&lt;p&gt;Method: for each package, take the latest published tarball from the registry, unpack it, and run a heuristic scan over every file — looking for source maps (and whether they carry &lt;code&gt;sourcesContent&lt;/code&gt;), environment files and credential formats, secret patterns, internal docs, coverage and debug output, and nested archives.&lt;/p&gt;

&lt;p&gt;This is a different view from a git secret scanner. A scanner reads your repository. But &lt;code&gt;npm pack&lt;/code&gt; doesn't mirror your repository:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If &lt;code&gt;package.json&lt;/code&gt; has a &lt;code&gt;files&lt;/code&gt; field, npm uses it as an allowlist and &lt;strong&gt;ignores &lt;code&gt;.npmignore&lt;/code&gt; entirely&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;If there's no &lt;code&gt;files&lt;/code&gt; field, npm falls back to &lt;code&gt;.npmignore&lt;/code&gt; — and the moment a &lt;code&gt;.npmignore&lt;/code&gt; exists, it &lt;strong&gt;replaces &lt;code&gt;.gitignore&lt;/code&gt;&lt;/strong&gt; for packaging purposes. Anything you excluded only in &lt;code&gt;.gitignore&lt;/code&gt; is back in play.&lt;/li&gt;
&lt;li&gt;Your &lt;code&gt;dist/&lt;/code&gt; folder is generated after all of this. Whatever the bundler emitted — maps included — is what ships.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So a repo can be perfectly clean and the tarball still leaks. The only reliable check is to inspect the artifact itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this looks like in practice
&lt;/h2&gt;

&lt;p&gt;These are ordinary, well-maintained packages. That's the point — none of this requires carelessness, just defaults nobody revisited.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;@hubspot/&lt;a href="mailto:api-client@14.1.3"&gt;api-client@14.1.3&lt;/a&gt;&lt;/strong&gt; ships 8,280 files, of which 2,759 are source maps.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;@langchain/&lt;a href="mailto:core@1.4.2"&gt;core@1.4.2&lt;/a&gt;&lt;/strong&gt; ships 684 source maps; 498 of them embed the full original source.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;@coinbase/&lt;a href="mailto:cdp-sdk@1.62.0"&gt;cdp-sdk@1.62.0&lt;/a&gt;&lt;/strong&gt; ships 1,134 source maps — and had 29 additional matches for secret patterns or sensitive file types. The report deliberately doesn't say which files; details go to the maintainer via a live scan, not onto a public page.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;@browserbasehq/&lt;a href="mailto:stagehand@4.4.0"&gt;stagehand@4.4.0&lt;/a&gt;&lt;/strong&gt; is a small package — 16 files — but one is a source map with full source embedded, and another is a nested archive (&lt;code&gt;dist/assets/stagehand-extension.zip&lt;/code&gt;), the kind of build leftover that's easy to ship without noticing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="mailto:cloudflare-api-js@4.35.0"&gt;cloudflare-api-js@4.35.0&lt;/a&gt;&lt;/strong&gt; manages 94.4 MB unpacked across just 36 files.&lt;/li&gt;
&lt;li&gt;At the other end: &lt;strong&gt;&lt;a href="mailto:react@19.3.1"&gt;react@19.3.1&lt;/a&gt;&lt;/strong&gt; ships 27 files with nothing flagged, and &lt;strong&gt;&lt;a href="mailto:chalk@6.0.1"&gt;chalk@6.0.1&lt;/a&gt;&lt;/strong&gt; ships 12. Generated SDKs and big CLIs have a harder job than a 12-file utility, but the gap between 27 files and 8,280 is configuration, not necessity.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Is a shipped source map actually a problem?
&lt;/h2&gt;

&lt;p&gt;It depends on the package, and the reports say so too. If your code is open source, the original is public anyway — the maps are mostly install weight, and they can genuinely help debugging. The calculus changes for closed-source SDKs and CLIs, internal packages published to public registries by mistake, and anything where comments and file structure are themselves information. A map with &lt;code&gt;sourcesContent&lt;/code&gt; is not a hint about your source. It is your source.&lt;/p&gt;

&lt;p&gt;The secret-pattern matches deserve the same nuance: a heuristic match is often a test fixture or a documentation example. Sometimes it isn't. Either way, the person who should find out first is the maintainer, before publish — not a reader after it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to do about it
&lt;/h2&gt;

&lt;p&gt;Four things, in order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Look at your own tarball.&lt;/strong&gt; &lt;code&gt;npm pack --dry-run&lt;/code&gt; lists exactly what will ship. If you have never read that list for your package, that's the whole problem in one sentence.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use a &lt;code&gt;files&lt;/code&gt; allowlist.&lt;/strong&gt; &lt;code&gt;"files": ["dist"]&lt;/code&gt; in &lt;code&gt;package.json&lt;/code&gt;, then narrow it — e.g. &lt;code&gt;"files": ["dist", "!dist/**/*.map"]&lt;/code&gt;. Remember that adding &lt;code&gt;files&lt;/code&gt; disables &lt;code&gt;.npmignore&lt;/code&gt;, so the allowlist has to be complete.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Decide about maps explicitly.&lt;/strong&gt; Strip them from release builds (&lt;code&gt;"sourceMap": false&lt;/code&gt;, or your bundler's equivalent), or upload them privately to your error tracker instead of the registry. Emitting them by default and shipping them by default are two separate decisions; most packages only ever made the first one.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;If something real already shipped, rotate first.&lt;/strong&gt; Excluding a file from the next release does not un-publish it — old versions stay on the registry. Rotate the credential, then fix the packaging.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Check yours
&lt;/h2&gt;

&lt;p&gt;Every finding above came from a build-config default nobody looked at. The check takes a minute: ReleaseShield's scanner is free, needs no login, and inspects the same artifact your users download — &lt;a href="https://releaseshield.lineanswered.com" rel="noopener noreferrer"&gt;scan your package&lt;/a&gt; or browse the &lt;a href="https://releaseshield.lineanswered.com/npm" rel="noopener noreferrer"&gt;per-package reports&lt;/a&gt; to see what your dependencies ship. If your tarball is clean, the report page for your package includes a badge you can put in your README so it stays that way:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;[![ReleaseShield](https://releaseshield.lineanswered.com/api/badge/npm/&amp;lt;your-package&amp;gt;.svg)](https://releaseshield.lineanswered.com/npm/&amp;lt;your-package&amp;gt;?ref=badge)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Method note: automated heuristic scan of each package's latest public tarball, figures recomputed on every crawl (last run 2026-11-21). Findings describe tarball contents; they are not a judgment of a package's security or its maintainers, and many flagged files are intentional.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>npm</category>
      <category>security</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
