Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More

@jridgewell/source-map

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jridgewell/source-map

Packages @jridgewell/trace-mapping and @jridgewell/gen-mapping into the familiar source-map API


Version published
Weekly downloads
22M
increased by5.03%
Maintainers
1
Weekly downloads
 
Created

What is @jridgewell/source-map?

The @jridgewell/source-map package is designed for creating, parsing, and manipulating source maps, which are files that map from the transformed source to the original source, enabling the browser to reconstruct the original source and present it to the developer. This is particularly useful for debugging minified code or code compiled from languages like TypeScript.

What are @jridgewell/source-map's main functionalities?

Generating a source map

This feature allows you to generate a source map by specifying the version, the output file name, the sources involved, the names used in the mappings, and the mappings themselves. The mappings detail how segments of the source are transformed and correspond to the generated code.

{"version":3,"file":"out.js","sources":["foo.js","bar.js"],"names":["src","maps","are","fun"],"mappings":"AAgBC,SAAQ,CAAEA"}

Parsing a source map

This feature enables the parsing of a source map from a string. It's useful for further manipulation or analysis of the source map, such as extracting information about the original sources or mappings.

const sourceMap = require('@jridgewell/source-map');
let parsedMap = sourceMap.parse('{"version":3,"sources":["foo.js"],"names":[],"mappings":"AAAA;AACA;AACA"}');

Adding and removing mappings

This demonstrates how to add and remove mappings from a source map. This is useful for dynamic manipulation of the source map, such as when merging source maps or making adjustments to the mappings.

const generator = new sourceMap.SourceMapGenerator({file: "out.js"});
generator.addMapping({generated: {line: 1, column: 0}, original: {line: 1, column: 0}, source: "foo.js"});
generator.removeMapping({generated: {line: 1, column: 0}, source: "foo.js"});

Other packages similar to @jridgewell/source-map

FAQs

Package last updated on 12 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts