react / wstein / node_modules / browserify / node_modules / browser-pack / node_modules / combine-source-map / example / two-files.js
80542 views'use strict';12var convert = require('convert-source-map');3var combine = require('..');45var foo = {6version : 3,7file : 'foo.js',8sourceRoot : '',9sources : [ 'foo.coffee' ],10names : [],11mappings : ';AAAA;CAAA;CAAA,CAAA,CAAA,IAAO,GAAK;CAAZ',12sourcesContent : [ 'console.log(require \'./bar.js\')\n' ] };1314var bar = {15version : 3,16file : 'bar.js',17sourceRoot : '',18sources : [ 'bar.coffee' ],19names : [],20mappings : ';AAAA;CAAA;CAAA,CAAA,CAAA,IAAO,GAAK;CAAZ',21sourcesContent : [ 'console.log(alert \'alerts suck\')\n' ] };222324var fooComment = convert.fromObject(foo).toComment();25var barComment = convert.fromObject(bar).toComment();2627var fooFile = {28source: '(function() {\n\n console.log(require(\'./bar.js\'));\n\n}).call(this);\n' + '\n' + fooComment29, sourceFile: 'foo.js'30};31var barFile = {32source: '(function() {\n\n console.log(alert(\'alerts suck\'));\n\n}).call(this);\n' + '\n' + barComment33, sourceFile: 'bar.js'34};3536var offset = { line: 2 };37var base64 = combine38.create('bundle.js')39.addFile(fooFile, offset)40.addFile(barFile, { line: offset.line + 8 })41.base64();4243var sm = convert.fromBase64(base64).toObject();44console.log('Combined source maps:\n', sm);45console.log('\nMappings:\n', sm.mappings);464748