@jridgewell/gen-mapping
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
@jridgewell/set-array | 1.2.1 | 17.52 kB | MIT | prod | |
@jridgewell/sourcemap-codec | 1.4.15 | 8.72 kB | MIT | prod | |
@jridgewell/trace-mapping | 0.3.25 | 165.36 kB | MIT | prod |
The @jridgewell/gen-mapping package is a tool that enables developers to generate source maps during the process of code transpilation or minification. This allows users to trace back to the original location in the source file for enhanced debugging. This feature can be useful either when using Chrome's DevTools or employing libraries such as @jridgewell/trace-mapping. You might be familiar with the source-map
package, as @jridgewell/gen-mapping provides the same addMapping
and setSourceContent
API.
To use @jridgewell/gen-mapping, developers need to first install the package through npm with this command: npm install @jridgewell/gen-mapping
. Once installed, you can use it in your code. Here's an example on how you add source content and mappings:
import { GenMapping, addMapping, setSourceContent, toEncodedMap, toDecodedMap } from '@jridgewell/gen-mapping';
const map = new GenMapping({
file: 'output.js',
sourceRoot: 'https://example.com/',
});
setSourceContent(map, 'input.js', `function foo() {}`);
addMapping(map, {
generated: { line: 1, column: 0 },
source: 'input.js',
original: { line: 1, column: 0 },
});
addMapping(map, {
generated: { line: 1, column: 9 },
source: 'input.js',
original: { line: 1, column: 9 },
name: 'foo',
});
For the @jridgewell/gen-mapping documentation, it is included in the read-me file of its GitHub page which is located at https://github.com/jridgewell/gen-mapping. The read-me file provides a comprehensive guide on how to use this package, including details for installation, usage, and API details. You'll also find benchmarks showing the package's performance compared to other similar solutions.