<?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: Karthik Ng</title>
    <description>The latest articles on DEV Community by Karthik Ng (@karthikng14).</description>
    <link>https://dev.to/karthikng14</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3567743%2Ff1dc59b0-bc97-4ba3-ab5e-cc0501b063b9.png</url>
      <title>DEV Community: Karthik Ng</title>
      <link>https://dev.to/karthikng14</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/karthikng14"/>
    <language>en</language>
    <item>
      <title>How I Accidentally Made My npm Package 324MB (and Fixed It)</title>
      <dc:creator>Karthik Ng</dc:creator>
      <pubDate>Wed, 15 Oct 2025 22:46:25 +0000</pubDate>
      <link>https://dev.to/karthikng14/how-i-accidentally-made-my-npm-package-324mb-and-fixed-it-1p14</link>
      <guid>https://dev.to/karthikng14/how-i-accidentally-made-my-npm-package-324mb-and-fixed-it-1p14</guid>
      <description>&lt;p&gt;Last week, I tried to create a CodeSandbox demo for my npm package. It failed. I tried to create a demo on &lt;a href="https://playcode.io/typescript" rel="noopener noreferrer"&gt;https://playcode.io/typescript&lt;/a&gt; and it failed again. &lt;/p&gt;

&lt;p&gt;The error message? &lt;code&gt;ENOSPC: no space left on device&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I stared at my screen, confused. Then I checked the package size.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;324MB.&lt;/strong&gt; 😱&lt;/p&gt;

&lt;p&gt;For context, React is about 6KB minified. My simple postal code lookup library was somehow &lt;strong&gt;54,000 times larger&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Here's the story of how I accidentally shipped a massive package to npm, how I fixed it, and what I learned building zero-dependency lookup libraries that are now used by developers worldwide.&lt;/p&gt;




&lt;h2&gt;
  
  
  🤔 Why I Built This
&lt;/h2&gt;

&lt;p&gt;It started with a simple need: I wanted to validate US ZIP codes in a React app.&lt;/p&gt;

&lt;p&gt;"Easy," I thought. "There must be dozens of npm packages for this."&lt;/p&gt;

&lt;p&gt;I was right - there were dozens. But each had issues:&lt;/p&gt;

&lt;p&gt;❌ &lt;strong&gt;Some only worked in Node.js&lt;/strong&gt; - couldn't use them in React&lt;br&gt;&lt;br&gt;
❌ &lt;strong&gt;Others required API calls&lt;/strong&gt; - rate limits, network latency, offline failures&lt;br&gt;&lt;br&gt;
❌ &lt;strong&gt;Many hadn't been updated in years&lt;/strong&gt; - broken, outdated data&lt;br&gt;&lt;br&gt;
❌ &lt;strong&gt;Several were huge&lt;/strong&gt; - 50MB+ packages with tons of dependencies&lt;br&gt;&lt;br&gt;
❌ &lt;strong&gt;Most lacked TypeScript support&lt;/strong&gt; - no autocomplete, no type safety&lt;/p&gt;

&lt;p&gt;I needed something that:&lt;/p&gt;

&lt;p&gt;✅ Works in browsers AND Node.js&lt;br&gt;&lt;br&gt;
✅ Zero runtime dependencies&lt;br&gt;&lt;br&gt;
✅ Full TypeScript support&lt;br&gt;&lt;br&gt;
✅ Returns city, state, county, and coordinates&lt;br&gt;&lt;br&gt;
✅ Actually maintained with fresh data&lt;/p&gt;

&lt;p&gt;When I couldn't find it, I decided to build it myself.&lt;/p&gt;

&lt;p&gt;Thus, &lt;strong&gt;&lt;a href="https://www.npmjs.com/package/zipcodes-us" rel="noopener noreferrer"&gt;zipcodes-us&lt;/a&gt;&lt;/strong&gt; was born.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(And later, &lt;strong&gt;&lt;a href="https://www.npmjs.com/package/postalcodes-india" rel="noopener noreferrer"&gt;postalcodes-india&lt;/a&gt;&lt;/strong&gt; for Indian postal codes)&lt;/em&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  💻 What It Does
&lt;/h2&gt;

&lt;p&gt;Here's the simplest example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;zipcodes&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;zipcodes-us&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;info&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;zipcodes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;90210&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;info&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;city&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Beverly Hills&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;California&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;stateCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;CA&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;county&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Los Angeles&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;latitude&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;34.0901&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;longitude&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;118.4065&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;isValid&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;a href="https://codesandbox.io/p/sandbox/little-haze-cc7h58" rel="noopener noreferrer"&gt;→ Try it live in CodeSandbox&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  More Cool Features
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Find all ZIP codes in a city:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bostonZips&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;zipcodes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findByCity&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Boston&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;MA&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// Returns array of all Boston ZIP codes with full info&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Search within a radius:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;nearby&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;zipcodes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findByRadius&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;37.7749&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;122.4194&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;// Find all ZIP codes within 10 miles of San Francisco&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Auto-complete addresses:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// User enters ZIP code, auto-fill city and state&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;city&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;zipcodes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userZipCode&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;addressForm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;city&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;city&lt;/span&gt;
&lt;span class="nx"&gt;addressForm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And it works &lt;strong&gt;exactly the same&lt;/strong&gt; in Node.js, React, Next.js, Vue, or vanilla JavaScript.&lt;/p&gt;




&lt;h2&gt;
  
  
  🐛 The 324MB Disaster
&lt;/h2&gt;

&lt;p&gt;Everything was working beautifully locally. I ran my tests, they passed. I built the package, published v1.1.1 to npm, and went to create a demo.&lt;/p&gt;

&lt;p&gt;I opened &lt;a href="https://playcode.io/typescript" rel="noopener noreferrer"&gt;https://playcode.io/typescript&lt;/a&gt;, created a new project, added my package...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;postalcodes-india
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And then... nothing. The installation hung. Eventually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Error: ENOSPC: no space left on device
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;"What?" I thought. "It's just a postal code lookup. How much space could it possibly need?"&lt;/p&gt;

&lt;p&gt;I checked &lt;a href="https://unpkg.com" rel="noopener noreferrer"&gt;unpkg.com&lt;/a&gt; to see what was actually published.&lt;/p&gt;

&lt;p&gt;My package was &lt;strong&gt;324MB&lt;/strong&gt;. My US ZIP code package? &lt;strong&gt;79MB&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For a simple lookup library with zero runtime dependencies.&lt;/p&gt;

&lt;h3&gt;
  
  
  🔍 Investigating the Problem
&lt;/h3&gt;

&lt;p&gt;I dove into the published package contents:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dist/
  index.js          (6.9MB)
  index.js.map      (15.1MB)  ← What are these?
  index.esm.js      (6.9MB)
  index.esm.js.map  (15.1MB)  ← These look huge
  index.umd.js      (6.2MB)
  index.umd.js.map  (11.9MB)  ← Oh no...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The culprit: Source map files (&lt;code&gt;.map&lt;/code&gt; files)&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  😱 What Are Source Maps?
&lt;/h3&gt;

&lt;p&gt;Source maps are debugging tools that map minified/compiled code back to your original source code. They're super useful during development:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Without source maps:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Error at line 1: function a(b){return c(b)}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(What does this mean?? 🤷)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;With source maps:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Error at line 42 in src/index.ts: 
  function findPostalCode(code) { 
    return lookup(code) 
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(Ah, now I can debug it! ✅)&lt;/p&gt;

&lt;h3&gt;
  
  
  🤦 The Problem
&lt;/h3&gt;

&lt;p&gt;Source maps are typically &lt;strong&gt;2-3x larger&lt;/strong&gt; than the actual code. And I was:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Generating them (fine for development)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Publishing them to npm&lt;/strong&gt; (not fine!)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;My Rollup configuration looked like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;src/index.ts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dist/index.esm.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;format&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;es&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;sourcemap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;// ← Creating massive .map files&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="c1"&gt;// ... similar for other builds&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That innocent &lt;code&gt;sourcemap: true&lt;/code&gt; was creating huge &lt;code&gt;.map&lt;/code&gt; files that were being published to npm, even though:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;❌ End users don't need them&lt;/li&gt;
&lt;li&gt;❌ They can't use them (they're for MY source code, not theirs)&lt;/li&gt;
&lt;li&gt;❌ They were making the package impossible to install in many environments&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ✅ The Fix
&lt;/h2&gt;

&lt;p&gt;The solution was surprisingly simple.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Update Rollup Config
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;src/index.ts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dist/index.esm.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;format&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;es&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;sourcemap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;// ← Changed from true to false&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="c1"&gt;// ... same for all builds&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Rebuild
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I checked the &lt;code&gt;dist/&lt;/code&gt; folder - no more &lt;code&gt;.map&lt;/code&gt; files! ✨&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Publish
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Bump version&lt;/span&gt;
&lt;span class="c"&gt;# Update package.json version to 1.1.2&lt;/span&gt;

npm publish
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  📊 The Results
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;zipcodes-us:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Before: 79MB&lt;/li&gt;
&lt;li&gt;After: 29.6MB&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reduction: 62.5%&lt;/strong&gt; 🎉&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;postalcodes-india:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Before: 324MB&lt;/li&gt;
&lt;li&gt;After: 137MB&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reduction: 58%&lt;/strong&gt; 🎉&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now CodeSandbox could actually install them. Crisis averted!&lt;/p&gt;




&lt;h2&gt;
  
  
  🎓 What I Learned
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Source Maps Are Not Needed in Production
&lt;/h3&gt;

&lt;p&gt;Source maps are development tools. They help YOU debug YOUR code. End users installing your package:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Don't have access to your source files&lt;/li&gt;
&lt;li&gt;Can't use the source maps anyway&lt;/li&gt;
&lt;li&gt;Just want the compiled code to work&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Lesson:&lt;/strong&gt; Turn off source maps for npm packages (&lt;code&gt;sourcemap: false&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exception:&lt;/strong&gt; Some argue you should ship source maps for debugging in production. If you do, consider:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Using &lt;code&gt;.npmignore&lt;/code&gt; to exclude them&lt;/li&gt;
&lt;li&gt;Or setting &lt;code&gt;"files": ["dist/**/*.js", "!dist/**/*.map"]&lt;/code&gt; in package.json&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Always Check Your Published Package
&lt;/h3&gt;

&lt;p&gt;Before v1.1.2, I never actually looked at what was being published to npm. I assumed Rollup was doing the right thing.&lt;/p&gt;

&lt;p&gt;Now I &lt;strong&gt;always&lt;/strong&gt; check:&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="c"&gt;# See what will be published&lt;/span&gt;
npm pack &lt;span class="nt"&gt;--dry-run&lt;/span&gt;

&lt;span class="c"&gt;# Or check on unpkg after publishing&lt;/span&gt;
https://unpkg.com/your-package@version/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Test in Real Environments
&lt;/h3&gt;

&lt;p&gt;My package worked perfectly on my local machine. But CodeSandbox, StackBlitz, and other online IDEs have disk space limits.&lt;/p&gt;

&lt;p&gt;If your package is too big, it won't work in these environments - and developers LOVE trying packages in online editors before installing locally.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lesson:&lt;/strong&gt; Create a CodeSandbox demo as part of your development process, not after publishing.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Package Size Matters
&lt;/h3&gt;

&lt;p&gt;I thought "it's just data, size doesn't matter." Wrong.&lt;/p&gt;

&lt;p&gt;Large packages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;❌ Take longer to install&lt;/li&gt;
&lt;li&gt;❌ Fill up disk space in CI/CD pipelines
&lt;/li&gt;
&lt;li&gt;❌ Can't be used in constrained environments&lt;/li&gt;
&lt;li&gt;❌ Increase &lt;code&gt;node_modules&lt;/code&gt; bloat&lt;/li&gt;
&lt;li&gt;❌ Make developers hesitant to use them&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Lesson:&lt;/strong&gt; Keep packages as small as possible. Every MB counts.&lt;/p&gt;




&lt;h2&gt;
  
  
  🏗️ Other Technical Challenges
&lt;/h2&gt;

&lt;p&gt;Fixing the package size wasn't the only challenge. Here are other things I learned:&lt;/p&gt;

&lt;h3&gt;
  
  
  Making It Work Everywhere
&lt;/h3&gt;

&lt;p&gt;The hardest part wasn't the lookup logic - it was making ONE package work in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Node.js (CommonJS - &lt;code&gt;require()&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Node.js (ESM - &lt;code&gt;import&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Browsers (via bundlers like Webpack/Vite)&lt;/li&gt;
&lt;li&gt;Browsers (via CDN &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tags)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The Solution: Multiple Build Targets
&lt;/h3&gt;

&lt;p&gt;I use Rollup to create three different builds:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="c1"&gt;// ESM for modern bundlers (Vite, Webpack 5)&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;src/index.ts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;format&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;es&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dist/index.esm.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;

  &lt;span class="c1"&gt;// CommonJS for Node.js&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;src/index.ts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;format&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cjs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dist/index.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;named&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;

  &lt;span class="c1"&gt;// UMD for browsers (script tags)&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;src/index.ts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;format&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;umd&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dist/index.umd.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;zipcodes&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then in &lt;code&gt;package.json&lt;/code&gt;, I specify which file to use for each environment:&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="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"zipcodes-us"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"main"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"dist/index.js"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Node.js&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;default&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;(CommonJS)&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"module"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"dist/index.esm.js"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Modern&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;bundlers&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;(ESM)&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"browser"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"dist/index.umd.js"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Browser&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;tag&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"types"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"dist/index.d.ts"&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;TypeScript&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;definitions&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now it just works, everywhere. Developers don't need to think about it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Keeping Data Fresh
&lt;/h3&gt;

&lt;p&gt;ZIP codes change! The USPS adds new ones, retires old ones, updates boundaries.&lt;/p&gt;

&lt;p&gt;I couldn't just ship v1.0 and forget about it. I needed a system to keep data current.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My solution:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Data comes from &lt;a href="https://www.geonames.org/" rel="noopener noreferrer"&gt;GeoNames&lt;/a&gt; (updated regularly, CC BY 4.0 license)&lt;/li&gt;
&lt;li&gt;I have a script which I run to check for updates. I try my best to check it daily.&lt;/li&gt;
&lt;li&gt;When changes are detected, I auto-generate a new data file&lt;/li&gt;
&lt;li&gt;Run tests to ensure nothing broke&lt;/li&gt;
&lt;li&gt;Publish a new version to npm&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The data check script runs as a GitHub Action. Completely automated.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lesson:&lt;/strong&gt; If your package depends on external data, plan for updates from day one.&lt;/p&gt;




&lt;h2&gt;
  
  
  📈 Results After Publishing the Fix
&lt;/h2&gt;

&lt;p&gt;After fixing the package size and improving documentation:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;zipcodes-us:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;📦 450+ weekly downloads&lt;/li&gt;
&lt;li&gt;⭐ 3 GitHub stars&lt;/li&gt;
&lt;li&gt;🐛 Zero open issues&lt;/li&gt;
&lt;li&gt;🌍 Used in production applications&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;postalcodes-india:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;📦 150+ weekly downloads
&lt;/li&gt;
&lt;li&gt;⭐ 1 GitHub stars&lt;/li&gt;
&lt;li&gt;🇮🇳 Covers all 19,000+ Indian postal codes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both packages are growing steadily. More importantly, they're &lt;strong&gt;actually useful&lt;/strong&gt; to real developers.&lt;/p&gt;




&lt;h2&gt;
  
  
  🎯 What's Next
&lt;/h2&gt;

&lt;p&gt;I'm working on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Performance optimizations&lt;/strong&gt; - can lookups be even faster?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;More search methods&lt;/strong&gt; - find by county, region, etc.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Better documentation&lt;/strong&gt; - more examples and use cases&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Maybe more countries?&lt;/strong&gt; - depends on demand&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The hardest part about maintaining open source isn't writing code - it's the ongoing commitment to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Respond to issues quickly&lt;/li&gt;
&lt;li&gt;Keep data updated&lt;/li&gt;
&lt;li&gt;Write good documentation
&lt;/li&gt;
&lt;li&gt;Help users when they're stuck&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But seeing my packages help other developers makes it worth it.&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 Try It Yourself
&lt;/h2&gt;

&lt;p&gt;If you need ZIP or postal code lookups in your project:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For US ZIP codes:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;npm:&lt;/strong&gt; &lt;a href="https://www.npmjs.com/package/zipcodes-us" rel="noopener noreferrer"&gt;zipcodes-us&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/ikarthikng/zipcodes-us" rel="noopener noreferrer"&gt;ikarthikng/zipcodes-us&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Demo:&lt;/strong&gt; &lt;a href="https://codesandbox.io/p/sandbox/little-haze-cc7h58" rel="noopener noreferrer"&gt;CodeSandbox&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;For Indian postal codes:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;npm:&lt;/strong&gt; &lt;a href="https://www.npmjs.com/package/postalcodes-india" rel="noopener noreferrer"&gt;postalcodes-india&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/ikarthikng/postalcodes-india" rel="noopener noreferrer"&gt;ikarthikng/postalcodes-india&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Demo:&lt;/strong&gt; &lt;a href="https://codesandbox.io/p/sandbox/awesome-tree-swv4kn" rel="noopener noreferrer"&gt;CodeSandbox&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Installation is simple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;zipcodes-us
&lt;span class="c"&gt;# or&lt;/span&gt;
npm &lt;span class="nb"&gt;install &lt;/span&gt;postalcodes-india
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And if you find bugs or have feature requests, I actually respond to GitHub issues! 😄&lt;/p&gt;




&lt;h2&gt;
  
  
  💭 Your Turn
&lt;/h2&gt;

&lt;p&gt;Have you ever shipped something way too big to npm? Made a similar mistake? I'd love to hear your stories in the comments!&lt;/p&gt;

&lt;p&gt;And if you're building your own npm packages, here's my advice:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;✅ Always check what you're actually publishing&lt;/li&gt;
&lt;li&gt;✅ Test in constrained environments (CodeSandbox, etc.)&lt;/li&gt;
&lt;li&gt;✅ Turn off source maps for production builds&lt;/li&gt;
&lt;li&gt;✅ Keep package size as small as possible&lt;/li&gt;
&lt;li&gt;✅ Provide TypeScript definitions (even if you write JS)&lt;/li&gt;
&lt;li&gt;✅ Create live demos - developers love to try before installing&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Happy coding! 🎉&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>typescript</category>
      <category>npm</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
