From 09d6e4aaa64bcdbf5c57b92d5bc8357b04d2da00 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 22 Sep 2014 13:17:21 -0700 Subject: [PATCH] Condition the custom serialization on the existance of JSON --- src/compiler/emitter.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) 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