Skip to content
This repository was archived by the owner on Jul 13, 2020. It is now read-only.

Commit c390257

Browse files
committed
Add //# sourceURL along with source map.
For some odd reason, Google Chrome requires sourceURL to be able to display source maps in stack traces correctly.
1 parent 86ee1d9 commit c390257

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

src/loader.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,8 +1103,10 @@ function logloads(loads) {
11031103

11041104
var sourceMap = compiler.getSourceMap();
11051105

1106-
if (__global.btoa && sourceMap)
1106+
if (__global.btoa && sourceMap) {
1107+
source += '\n//# sourceURL=' + load.address + '!eval';
11071108
source += '\n//# sourceMappingURL=data:application/json;base64,' + btoa(unescape(encodeURIComponent(sourceMap))) + '\n';
1109+
}
11081110

11091111
source = 'var __moduleAddress = "' + load.address + '";' + source;
11101112

test/manual/source-maps/test.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html>
3+
4+
<body>
5+
<h1>Source Map Stack Trace Test</h1>
6+
<script src="../../../node_modules/traceur/bin/traceur.js"></script>
7+
<script src="../../../dist/es6-module-loader.src.js"></script>
8+
<script>
9+
System.import('test').then(function(module) {
10+
console.log(module.make().stack)
11+
})
12+
</script>
13+
</body>

test/manual/source-maps/test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export function make() {
2+
return new Error('Hello')
3+
}
4+

0 commit comments

Comments
 (0)