gitwtfhub

wtf is source-map?

mozilla/source-map — explained in plain English

Analysis updated 2026-07-03

3,723JavaScriptAudience · developerComplexity · 2/5Setup · easy

TL;DR

A JavaScript library from Mozilla for creating and reading source maps, the files that connect minified browser code back to original source lines so error messages show useful locations instead of compressed gibberish.

Mindmap

mindmap
  root((source-map))
    What it does
      Generate source maps
      Consume source maps
      Map code positions
    Tech Stack
      JavaScript
      WebAssembly module
      Node.js and browser
    Use Cases
      Build tooling
      Error debugging
      Stack trace lookup
    Audience
      Tooling developers
      Build system authors

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Why would anyone build with this?

REASON 1

Add source map generation to a custom JavaScript build tool so compiled output points back to the original source files for debugging.

REASON 2

Look up which original file and line number a position in a minified production bundle came from to diagnose a real-world error.

REASON 3

Consume a source map from a third-party library to produce readable stack traces in an error monitoring or logging tool.

What's in the stack?

JavaScriptWebAssemblyNode.js

How it stacks up

mozilla/source-mapbritecharts/britechartszhongerxin/cowart
Stars3,7233,7223,724
LanguageJavaScriptJavaScriptJavaScript
Last pushed2026-07-03
MaintenanceActive
Setup difficultyeasyeasyeasy
Complexity2/52/52/5
Audiencedeveloperdeveloperdesigner

Figures from each repo's GitHub metadata at analysis time.

How do you spin it up?

Difficulty · easy Time to first run · 30min

Browser usage requires a one-time async initialization step to load and point the library at the compiled WebAssembly file.

Wtf does this do

Source Map is a JavaScript library from Mozilla for reading and writing source maps. A source map is a file that connects minified or compiled code back to the original source files that produced it. When something goes wrong in a web app and you see an error in the browser's developer tools, the error normally points to a line in a compressed, unreadable file. A source map lets the browser show you the corresponding line in the original, human-readable code instead. This library handles both directions. You can use it to generate source maps when building a tool that transforms or compiles JavaScript, and you can use it to consume existing source maps to look up where a position in generated code came from in the original source. It works in Node.js (installed via npm) and in the browser (loaded via a script tag). The library uses a WebAssembly component to process mappings efficiently, which is why browser usage requires a short initialization step to point the library at the compiled WebAssembly file. The README is detailed and documents the full API surface, including a high-level interface for building source maps incrementally and a lower-level interface for adding mappings individually. The project is maintained by Mozilla and is released as an open source npm package. The full README is longer than what was shown.

Yoink these prompts

Prompt 1
I'm writing a JavaScript code transformer and want to generate a source map so browsers show the original source in the debugger. Show me how to use mozilla/source-map to build the map incrementally as I transform each node.
Prompt 2
I have a minified JavaScript file and its source map. How do I use mozilla/source-map to look up which original file and line number corresponds to a specific position in the minified output?
Prompt 3
How do I set up mozilla/source-map in a browser project, including the async initialization step needed to load the WebAssembly component?
Prompt 4
Show me how to use mozilla/source-map to merge two source maps from separate compilation steps into a single final map that points all the way back to the original source.

Frequently asked questions

wtf is source-map?

A JavaScript library from Mozilla for creating and reading source maps, the files that connect minified browser code back to original source lines so error messages show useful locations instead of compressed gibberish.

What language is source-map written in?

Mainly JavaScript. The stack also includes JavaScript, WebAssembly, Node.js.

How hard is source-map to set up?

Setup difficulty is rated easy, with roughly 30min to a first successful run.

Who is source-map for?

Mainly developer.

View the repo → Decode another repo

This repo across BitVibe Labs

Don't trust strangers blindly. Verify against the repo.