# @jridgewell/trace-mapping — card for AI agents

Library for resolving original positions through source maps for debugging.

Category: Dev workflow and config · npm package `@jridgewell/trace-mapping` · latest version 0.3.31 (checked 2026-11-01)
Install: `npm install @jridgewell/trace-mapping`
License: MIT (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Numbers (AgentGid data)
- Gid Score: 56.2 (#1336 of all tools, 106 of 299 in its category)
- Used in 16 public projects set up for AI coding agents (0.3%)
- Downloads last week: 388,559,429 (as of 2026-11-24), +39.2% over 4 weeks
- GitHub stars: 61 (as of 2026-11-24)
- Last push: 2026-10-27

## Often used with
Vite 96.6%, Radix UI 94.9%, Class Variance Authority 94.9%, clsx 94.9%, Lucide React 94.9%, Tailwind Merge 94.9%

## Links
- AgentGid page: https://agentgid.com/tools/jridgewell-trace-mapping/
- Homepage: https://github.com/jridgewell/sourcemaps/tree/main/packages/trace-mapping
- Repository: https://github.com/jridgewell/sourcemaps


## @jridgewell/trace-mapping: find the real line behind an error

@jridgewell/trace-mapping is a small free JavaScript library for source maps. When an error points to line 1, column 91 of a squeezed one-line file, it tells you the file, line and column in the code you actually wrote. Error reports and developer tools use it to show readable locations.

### Where to use it
- Readable errors from live sites: Visitors hit an error in your shipped, squeezed code. Your error log turns "bundle.min.js:1:91" into "src/cart.js line 8" before you read it.
- Show the code next to an error: An internal error page or a bug report shows the few lines of original code around the failing line, read from the source map itself.
- Jump from source to shipped code: A tool knows a line in your source file and needs the matching spot in the built file, for example to place a marker or a breakpoint.
- Hide library code in stack traces: Your error view greys out frames that come from third-party packages, so the lines from your own code stand out.
- Swap out a heavier source map reader: A build or test tool that used the older source-map package keeps the same lookups without loading WebAssembly.

### How to start
- Add the package to your project.

```
npm install @jridgewell/trace-mapping
```

- Load a source map into a TraceMap and ask for the original spot of a line and column.

```
import { TraceMap, originalPositionFor } from '@jridgewell/trace-mapping';
const tracer = new TraceMap(map);
// Lines start at line 1, columns at column 0.
const traced = originalPositionFor(tracer, { line: 1, column: 5 });
```

- For maps glued from several parts (a rare "sections" format), load them with AnyMap instead.

```
import { AnyMap } from '@jridgewell/trace-mapping';
```


### License
Free to use, also in paid products, under the MIT license. Keep the copyright and permission notice with copies of its code.

### Good to know
- It reads source maps; it does not make them. Your build tool has to produce the .map files.
- Lines count from 1 and columns from 0. Browser stack traces count columns from 1, so subtract 1 first.
- The code now lives in a shared source maps project with its sister packages; the old standalone home is archived.
- Version numbers are still 0.3.x; the latest, 0.3.31, came out in September 2025.
- It installs two small helper packages from the same project, one to decode maps and one to join file paths.

Checked 2026-11-10 against: https://github.com/jridgewell/sourcemaps/blob/main/packages/trace-mapping/README.md, https://github.com/jridgewell/sourcemaps/blob/main/packages/trace-mapping/LICENSE, https://github.com/jridgewell/sourcemaps/blob/main/packages/trace-mapping/package.json, https://github.com/jridgewell/sourcemaps/blob/main/README.md, https://github.com/jridgewell/trace-mapping, https://registry.npmjs.org/@jridgewell/trace-mapping, https://registry.npmjs.org/@jridgewell/trace-mapping/0.3.31, https://registry.npmjs.org/@jridgewell/sourcemap-codec, https://registry.npmjs.org/@jridgewell/resolve-uri

### Mistakes to avoid
- Don't: originalPositionFor(tracer, { line: 1, column: 91 }) with the column copied from a stack trace → Do: Pass column: stackColumn - 1; lines stay as they are (The library counts columns from 0, stack traces from 1; our run needed column 90 for "bundle.min.js:1:91".)
- Don't: traceSegment(tracer, 1, 5) with the same 1-based line you give originalPositionFor → Do: traceSegment(tracer, 0, 5); traceSegment takes 0-based lines (The low-level call counts lines from 0, unlike originalPositionFor.)
- Don't: new SourceMapConsumer(map) and consumer.originalPositionFor({...}) from the source-map package → Do: const tracer = new TraceMap(map); originalPositionFor(tracer, {...}) as plain imported functions (The lookups have the same names but are separate functions that take the TraceMap first.)
- Don't: Printing pos.source and pos.line without checking them → Do: if (pos.source === null) keep the original frame; only rewrite frames that traced (A spot with no mapping returns source, line, column and name all null; our run got that for a column before the first mapping.)
- Don't: new TraceMap(sectionedMap) for a map that has a sections field → Do: new AnyMap(sectionedMap) (also exported as FlattenMap in 0.3.31) (Sectioned maps need the AnyMap helper, which returns a normal TraceMap.)

### Questions
- Does it need WebAssembly? No. It offers the same lookups as the older source-map package without WebAssembly.
- Why do I get an error about line 0? Lines start at 1. In our run, line 0 threw "line must be greater than 0 (lines start at line 1)".
- Can it show the original code, not only the line number? Yes, when the map includes the source text; sourceContentFor returns it.
- Can I use it in a paid product? Yes. It is MIT; keep the notice with copies of the code.

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
