UNPKG

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