Search


Search something to see results

SourceMap

Generate and parse source map

const sourcemap = new SourceMap();

// you can also pass an input sourcemap
// const sourcemap = new SourceMap(sourcemapObjectOrJSONString);

sourcemap.addSourceContent(0, '/css/styles.css', null);
sourcemap.addSourceContent(1, '/css/typography.css', null);

const maps = [];

maps.add([
1, 1, 0, 1, 1]);
maps.add([
2, 1, 1, 1, 1
]);

sourcemap.add(maps);

// convert to inline sourcemap
sourcemap.toUrl();

// convert to JSON
sourcemap.toJSON();

// find the original file, line and column
sourcemap.find(2, 1);

Index

Constructors

Methods

Constructor

Returns SourceMap

Constructor

Parameters

Returns SourceMap

Add multiple sourcemaps

Parameters

  • maps: [newLine: number, newColumn: number, srcId: number, ln: number, col: number][]

Returns void

add source

Parameters

  • id: number

    source id

  • fileName: string | null

    source file

  • content: string | null

    source content

Returns void

compute original positions

Returns void

retrieve original sources, lines and columns

Parameters

  • line: number

    generated line

  • column: number

    generated column

Returns [string | null, number, number, string | null][] | null

Convert to JSON object

Returns SourceMapObject

Convert to URL encoded string

Returns string