1 | 'use strict';
|
2 |
|
3 | var convert = require('convert-source-map');
|
4 | var parse = require('parse-base64vlq-mappings');
|
5 | var combine = require('..');
|
6 |
|
7 | var 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 |
|
16 | var 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 |
|
26 | var fooComment = convert.fromObject(foo).toComment();
|
27 | var barComment = convert.fromObject(bar).toComment();
|
28 |
|
29 | var fooFile = {
|
30 | source: '(function() {\n\n console.log(require(\'./bar.js\'));\n\n}).call(this);\n' + '\n' + fooComment
|
31 | , sourceFile: 'foo.js'
|
32 | };
|
33 | var barFile = {
|
34 | source: '(function() {\n\n console.log(alert(\'alerts suck\'));\n\n}).call(this);\n' + '\n' + barComment
|
35 | , sourceFile: 'bar.js'
|
36 | };
|
37 |
|
38 | var offset = { line: 2 };
|
39 | var base64 = combine
|
40 | .create('bundle.js')
|
41 | .addFile(fooFile, offset)
|
42 | .addFile(barFile, { line: offset.line + 8 })
|
43 | .base64();
|
44 |
|
45 | var sm = convert.fromBase64(base64).toObject();
|
46 | console.log('Combined source maps:\n', sm);
|
47 | console.log('\nMappings:\n', parse(sm.mappings));
|