Modern source map link discovery and resolution helpers for JavaScript and TypeScript.
source-map-resolve is deprecated. This package keeps the useful migration concepts: find a sourceMappingURL, parse external or inline source maps, resolve source file URLs, and optionally load source contents. The API is promise-first with sync helpers for build tools.
npm install source-map-linksimport { resolveSourceMap, resolveSources } from "source-map-links";
const result = await resolveSourceMap(code, "/js/app.js", readText);
if (result) {
const sources = await resolveSources(result.map, result.sourcesRelativeTo, readText);
console.log(sources.sourcesResolved);
}Inline data URLs are supported:
import { findSourceMappingURL, parseMapToJSON } from "source-map-links";
const link = findSourceMappingURL(code);
const map = parseMapToJSON(json);Returns the last sourceMappingURL comment value in JavaScript or CSS code.
Strips the source map XSSI prefix and parses JSON. If parsing fails, the thrown error has sourceMapData.
Finds and loads the referenced source map. Returns null when no link exists.
Resolves source URLs and loads source contents where possible.
Convenience helper that resolves the source map and sources.
resolveSourceMapSync, resolveSourcesSync, and resolveSync are available for synchronous build pipelines.
source-map-links is an independent alternative or migration helper for projects moving away from source-map-resolve. It is not affiliated with the original package maintainers or project.
For release context, see the local migration guide, examples, compatibility notes, source metadata, and adoption plan.