How to use source-map

Comprehensive source-map code examples:

How to use source-map.fromStringWithSourceMap:

33
34
35
36
37
38
39
40
41
42
			sourceMap.setSourceContent(this._name, this._originalSource);
		innerSourceMap = new SourceMapConsumer(innerSourceMap);
		sourceMap.applySourceMap(innerSourceMap, this._name);
		sourceMap = sourceMap.toJSON();
	}
	return SourceNode.fromStringWithSourceMap(this._value, new SourceMapConsumer(sourceMap));
}

listMap(options) {
	options = options || {};

How to use source-map.SourceMapGenerator:

9
10
11
12
13
14
15
16
17
18
var through = require('through');
var UglifyJS = require('uglify-js');
var UglifyCSS = require('uglifycss');

var SourceMapConsumer = sourceMap.SourceMapConsumer;
var SourceMapGenerator = sourceMap.SourceMapGenerator;
var SourceNode = sourceMap.SourceNode;


// Uglify emits ugly warnings for source maps it can't resolve.

How to use source-map.SourceNode:

10
11
12
13
14
15
16
17
18
19
var UglifyJS = require('uglify-js');
var UglifyCSS = require('uglifycss');

var SourceMapConsumer = sourceMap.SourceMapConsumer;
var SourceMapGenerator = sourceMap.SourceMapGenerator;
var SourceNode = sourceMap.SourceNode;


// Uglify emits ugly warnings for source maps it can't resolve.
// It cannot map our license preamble or the browserify wrappers.

How to use source-map.SourceMapConsumer:

8
9
10
11
12
13
14
15
16
var sourceMap = require('source-map');
var through = require('through');
var UglifyJS = require('uglify-js');
var UglifyCSS = require('uglifycss');

var SourceMapConsumer = sourceMap.SourceMapConsumer;
var SourceMapGenerator = sourceMap.SourceMapGenerator;
var SourceNode = sourceMap.SourceNode;