diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 397ae1791a8..77fbc7902c8 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -604,6 +604,17 @@ module ts { }; function serializeSourceMapContents(version: number, file: string, sourceRoot: string, sources: string[], names: string[], mappings: string) { + if (typeof JSON !== "undefined") { + return JSON.stringify({ + version: version, + file: file, + sourceRoot: sourceRoot, + sources: sources, + names: names, + mappings: mappings + }); + } + return "{\"version\":" + version + ",\"file\":\"" + escapeString(file) + "\",\"sourceRoot\":\"" + escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + escapeString(mappings) + "\"}"; /** This does not support the full escape characters, it only supports the subset that can be used in file names