@@ -588,17 +588,33 @@ module ts {
588588 recordSourceMapSpan ( comment . end ) ;
589589 }
590590
591+ function serializeStringArray ( list : string [ ] ) : string {
592+ if ( list && list . length ) {
593+ return "\"" + list . join ( "\",\"" ) + "\"" ;
594+ }
595+ return "" ;
596+ //var output = "";
597+ //for (var i = 0, n = list.length; i < n; i++) {
598+ // if (i) output += ",";
599+ // output += "\"" + list[i] + "\"";
600+ //}
601+ //return output;
602+ }
603+
604+ function serializeSourceMapContents ( version : number , file : string , sourceRoot : string , sources : string [ ] , names : string [ ] , mappings : string ) {
605+ return "{\"version\":" + version + ",\"file\":\"" + file + "\",\"sourceRoot\":\"" + sourceRoot + "\",\"sources\":[" + serializeStringArray ( sources ) + "],\"names\":[" + serializeStringArray ( names ) + "],\"mappings\":\"" + mappings + "\"}" ;
606+ }
607+
591608 function writeJavaScriptAndSourceMapFile ( emitOutput : string , writeByteOrderMark : boolean ) {
592609 // Write source map file
593610 encodeLastRecordedSourceMapSpan ( ) ;
594- writeFile ( sourceMapData . sourceMapFilePath , JSON . stringify ( {
595- version : 3 ,
596- file : sourceMapData . sourceMapFile ,
597- sourceRoot : sourceMapData . sourceMapSourceRoot ,
598- sources : sourceMapData . sourceMapSources ,
599- names : sourceMapData . sourceMapNames ,
600- mappings : sourceMapData . sourceMapMappings
601- } ) , /*writeByteOrderMark*/ false ) ;
611+ writeFile ( sourceMapData . sourceMapFilePath , serializeSourceMapContents (
612+ 3 ,
613+ sourceMapData . sourceMapFile ,
614+ sourceMapData . sourceMapSourceRoot ,
615+ sourceMapData . sourceMapSources ,
616+ sourceMapData . sourceMapNames ,
617+ sourceMapData . sourceMapMappings ) , /*writeByteOrderMark*/ false ) ;
602618 sourceMapDataList . push ( sourceMapData ) ;
603619
604620 // Write sourcemap url to the js file and write the js file
0 commit comments