Index: lib/src/runner/browser/compiler_pool.dart |
diff --git a/lib/src/runner/browser/compiler_pool.dart b/lib/src/runner/browser/compiler_pool.dart |
index edeefaec8a08c31a25ca142744d1c7f96a8d9252..edc41bf20dd41f7191d43ea6518273063be29d6d 100644 |
--- a/lib/src/runner/browser/compiler_pool.dart |
+++ b/lib/src/runner/browser/compiler_pool.dart |
@@ -105,13 +105,30 @@ void main(_) { |
if (buffer.isNotEmpty) print(buffer); |
- if (exitCode != 0) { |
- throw new LoadException(dartPath, "dart2js failed."); |
- } |
+ if (exitCode != 0) throw new LoadException(dartPath, "dart2js failed."); |
+ |
+ _fixSourceMap(jsPath + '.map'); |
}); |
}); |
} |
+ // TODO(nweiz): Remove this when sdk#17544 is fixed. |
+ /// Fix up the source map at [mapPath] so that it points to absolute file: |
+ /// URIs that are resolvable by the browser. |
+ void _fixSourceMap(String mapPath) { |
+ var map = JSON.decode(new File(mapPath).readAsStringSync()); |
+ var root = map['sourceRoot']; |
+ |
+ map['sources'] = map['sources'].map((source) { |
+ var url = Uri.parse(root + source); |
+ if (url.scheme != '' && url.scheme != 'file') return source; |
+ if (url.path.endsWith("/runInBrowser.dart")) return ""; |
+ return p.toUri(mapPath).resolveUri(url).toString(); |
+ }).toList(); |
+ |
+ new File(mapPath).writeAsStringSync(JSON.encode(map)); |
+ } |
+ |
/// Sanitizes the bytes emitted by [stream], converts them to text, and writes |
/// them to [buffer]. |
Future _printOutputStream(Stream<List<int>> stream, StringBuffer buffer) { |