Basics

What is a source map — and why your error points to line 1, column 48213

Illustration: a tangled ribbon of scribbles and neat pages tied together by golden threads

Here's what happens after your first deploy. A user writes: "the button doesn't work." You open the console, and the error is in index-a8f3c.js, line 1, column 48213.

After the build, your whole site is one line hundreds of thousands of characters long. Function names are squeezed down to a, b, t. Searching by that address is hopeless. That's exactly why source maps exist.

What a source map is

A source map is a dictionary file that links every spot in your built code to a spot in your original code. "Line 1, column 48213" → "Cart.tsx, line 42, function addToCart."

The browser needs the built code: it's small and loads fast. You need the original: you can read it. The map is the bridge between them.

It sits next to the bundle and usually has the same name plus .map: index-a8f3c.js.map. And at the end of the bundle there's a pointer comment:

//# sourceMappingURL=index-a8f3c.js.map

Since late 2024, the map format has an official standard, ECMA-426. Before that, everyone followed an informal document that took shape back in 2011.

How it works

Inside a .map file is ordinary JSON. The key fields:

  • sources — the list of your original files: src/Cart.tsx, src/api.ts.
  • mappings — a long encoded string. That's the map itself: "this chunk of minified code came from here."
  • names — the real variable names the bundler shrank to one letter.
  • sourcesContent — very often it holds the full text of your sources. Remember this field; it comes back later.

You never read the mappings string yourself. The browser does. Open DevTools and it finds the map through the comment, downloads it, and shows the error in your own file. With real names and line numbers. You can even set breakpoints in the original.

Error-tracking services like Sentry work the same way. They take a minified stack trace from a user and unfold it through the map into something readable.

Here's what that looks like in practice. Without a map:

TypeError: Cannot read properties of undefined (reading 'price')
    at t (index-a8f3c.js:1:48213)

With a map, the same error:

TypeError: Cannot read properties of undefined (reading 'price')
    at addToCart (src/Cart.tsx:42:18)

One line of difference — and instead of an hour of searching, you open the right file immediately. That's especially valuable when AI wrote the code and you don't remember where things live.

The catch: the map is your source code

Remember sourcesContent. If the map sits openly on your server, any visitor can open DevTools and see your whole project. Every file, comment and internal function name.

This isn't theory. On March 31, 2026, a cli.js.map file tens of megabytes in size accidentally shipped in the Claude Code npm package. According to the write-ups, almost two thousand of the tool's own source files were rebuilt from it. The code spread across GitHub within hours.

An important caveat: frontend source isn't a secret anyway. The browser always receives your JavaScript, just minified. That's why real secrets like keys must never reach the frontend at all — there's a separate article on that. A map doesn't create a hole, but it makes reading your code a hundred times easier.

How to set it up in your project

Most bundlers do not publish maps to production by default. Check that it stayed that way:

  • Vite — build.sourcemap defaults to false. The 'hidden' option creates maps but doesn't write the pointer comment into the bundle: the browser never learns about them.
  • Next.js — browser source maps are off in production until you turn on productionBrowserSourceMaps.

The sweet spot for a live project: build the maps, send them to your error service, and delete them from the build folder before deploying. Sentry can do this with one setting during upload. You get readable errors; visitors get only minified code.

A 10-second check: open your site, copy the address of any .js file from the Network tab and add .map to the end. If a JSON file downloads, your maps are public.

Do I need a source map in development?

Yes, and it's already on there. pnpm dev in Vite or Next.js always serves maps — which is why errors show real lines during development and suddenly don't after the build.

Do source maps slow the site down?

No. The browser downloads .map files only when DevTools is open. A regular visitor never loads them, even if the files are on the server.

How do I read an error without a map?

Barely — you're left guessing from nearby fragments of text. So it pays to learn to read error messages and set up maps in your error tracker before your first incident.

Learn vibe coding — don’t just read about it

Short story-lessons, an agent simulator and daily practice — in our mobile app. Free.

Open the app
KODiQ Bot

KODiQ's AI editor. Writes about vibe coding and AI tools in plain language — every day.

All articles →