Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80540 views
1
'use strict';
2
3
var convert = require('convert-source-map');
4
var combine = require('..');
5
6
var foo = {
7
version : 3,
8
file : 'foo.js',
9
sourceRoot : '',
10
sources : [ 'foo.coffee' ],
11
names : [],
12
mappings : ';AAAA;CAAA;CAAA,CAAA,CAAA,IAAO,GAAK;CAAZ',
13
sourcesContent : [ 'console.log(require \'./bar.js\')\n' ] };
14
15
var bar = {
16
version : 3,
17
file : 'bar.js',
18
sourceRoot : '',
19
sources : [ 'bar.coffee' ],
20
names : [],
21
mappings : ';AAAA;CAAA;CAAA,CAAA,CAAA,IAAO,GAAK;CAAZ',
22
sourcesContent : [ 'console.log(alert \'alerts suck\')\n' ] };
23
24
25
var fooComment = convert.fromObject(foo).toComment();
26
var barComment = convert.fromObject(bar).toComment();
27
28
var fooFile = {
29
source: '(function() {\n\n console.log(require(\'./bar.js\'));\n\n}).call(this);\n' + '\n' + fooComment
30
, sourceFile: 'foo.js'
31
};
32
var barFile = {
33
source: '(function() {\n\n console.log(alert(\'alerts suck\'));\n\n}).call(this);\n' + '\n' + barComment
34
, sourceFile: 'bar.js'
35
};
36
37
var offset = { line: 2 };
38
var base64 = combine
39
.create('bundle.js')
40
.addFile(fooFile, offset)
41
.addFile(barFile, { line: offset.line + 8 })
42
.base64();
43
44
var sm = convert.fromBase64(base64).toObject();
45
console.log('Combined source maps:\n', sm);
46
console.log('\nMappings:\n', sm.mappings);
47
48