@@ -588,17 +588,33 @@ module ts {
588
588
recordSourceMapSpan ( comment . end ) ;
589
589
}
590
590
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
+
591
608
function writeJavaScriptAndSourceMapFile ( emitOutput : string , writeByteOrderMark : boolean ) {
592
609
// Write source map file
593
610
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 ) ;
602
618
sourceMapDataList . push ( sourceMapData ) ;
603
619
604
620
// Write sourcemap url to the js file and write the js file
0 commit comments