{"action":"created","issue":{"url":"https://api.github.com/repos/ModuleLoader/es6-module-loader/issues/355","labels_url":"https://api.github.com/repos/ModuleLoader/es6-module-loader/issues/355/labels{/name}","comments_url":"https://api.github.com/repos/ModuleLoader/es6-module-loader/issues/355/comments","events_url":"https://api.github.com/repos/ModuleLoader/es6-module-loader/issues/355/events","html_url":"https://github.com/ModuleLoader/es6-module-loader/issues/355","id":67237032,"number":355,"title":"no module name in exception call stack for modules transpiled with traceur","user":{"login":"metamatt","id":313893,"avatar_url":"https://avatars.githubusercontent.com/u/313893?v=3","gravatar_id":"","url":"https://api.github.com/users/metamatt","html_url":"https://github.com/metamatt","followers_url":"https://api.github.com/users/metamatt/followers","following_url":"https://api.github.com/users/metamatt/following{/other_user}","gists_url":"https://api.github.com/users/metamatt/gists{/gist_id}","starred_url":"https://api.github.com/users/metamatt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metamatt/subscriptions","organizations_url":"https://api.github.com/users/metamatt/orgs","repos_url":"https://api.github.com/users/metamatt/repos","events_url":"https://api.github.com/users/metamatt/events{/privacy}","received_events_url":"https://api.github.com/users/metamatt/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-04-08T22:49:04Z","updated_at":"2015-04-08T23:17:45Z","closed_at":null,"body":"I just started learning systemjs. Please excuse me if I'm doing something drastically wrong on my end.\r\n\r\nI whipped up a simple ES6 module and, because I'm concerned about debuggability of transpiled code, immediately decided to see what the error messages and call stacks look like.\r\n\r\nI tried throwing an Error from the toplevel of the ES6 module with just `throw new Error('testError');`:\r\n\r\n```\r\nes6-module-loader.src.js:140 Potentially unhandled rejection [2] Error: testError\r\n    at System.register.execute (eval at __eval (http://localhost:1080/s/pkg/es6-module-loader.js:7:12622), <anonymous>:21:13)\r\n    at t (http://localhost:1080/s/pkg/es6-module-loader.js:7:19790)\r\n    at v (http://localhost:1080/s/pkg/es6-module-loader.js:7:20172)\r\n    at u (http://localhost:1080/s/pkg/es6-module-loader.js:7:19848)\r\n    at s (http://localhost:1080/s/pkg/es6-module-loader.js:7:19729)\r\n    at http://localhost:1080/s/pkg/es6-module-loader.js:7:22056\r\n    at O (http://localhost:1080/s/pkg/es6-module-loader.js:7:7439)\r\n    at K (http://localhost:1080/s/pkg/es6-module-loader.js:7:7071)\r\n    at y.7.y.when (http://localhost:1080/s/pkg/es6-module-loader.js:7:10745)\r\n    at v.7.v.run (http://localhost:1080/s/pkg/es6-module-loader.js:7:9781)\r\n```\r\n\r\nand throwing the same error using Angular and $timeout:\r\n\r\n```\r\nError: testError\r\n    at eval (eval at __eval (http://localhost:1080/s/pkg/es6-module-loader.js:7:12622), <anonymous>:21:17)\r\n    at http://localhost:1080/s/pkg/github/angular/bower-angular@1.4.0-beta.6/angular.js:17105:31\r\n    at completeOutstandingRequest (http://localhost:1080/s/pkg/github/angular/bower-angular@1.4.0-beta.6/angular.js:5073:10)\r\n    at http://localhost:1080/s/pkg/github/angular/bower-angular@1.4.0-beta.6/angular.js:5335:7\r\n```\r\n\r\nThe way I understand using `eval` to transpile code, this should work if you pass the browser a nice label for the source string that you `eval`, by sticking a `//# sourceURL=` annotation in there. I went looking for that in the es6-module-loader code and found it in the Babel transpile path, but not in the (otherwise similar) Traceur transpile path:\r\n\r\n```\r\n    // add \"!eval\" to end of Traceur sourceURL\r\n    // I believe this does something?\r\n    source += '!eval';\r\n```\r\n\r\n```\r\n    // add \"!eval\" to end of Babel sourceURL\r\n    // I believe this does something?\r\n    return source + '\\n//# sourceURL=' + load.address + '!eval';\r\n```\r\n\r\nI tried configuring sytemjs to transpile with babel instead of traceur, and I get much nicer call stacks:\r\n\r\n```\r\nPotentially unhandled rejection [2] Error: testError\r\n    at System.register.execute (http://localhost:1080/s/loader/loader.js!eval:21:16)\r\n    at t (http://localhost:1080/s/pkg/es6-module-loader.js:7:19790)\r\n    at v (http://localhost:1080/s/pkg/es6-module-loader.js:7:20172)\r\n    at u (http://localhost:1080/s/pkg/es6-module-loader.js:7:19848)\r\n    at s (http://localhost:1080/s/pkg/es6-module-loader.js:7:19729)\r\n    at http://localhost:1080/s/pkg/es6-module-loader.js:7:22056\r\n    at O (http://localhost:1080/s/pkg/es6-module-loader.js:7:7439)\r\n    at K (http://localhost:1080/s/pkg/es6-module-loader.js:7:7071)\r\n    at y.7.y.when (http://localhost:1080/s/pkg/es6-module-loader.js:7:10745)\r\n    at v.7.v.run (http://localhost:1080/s/pkg/es6-module-loader.js:7:9781)\r\n```\r\n\r\nBut much longer load time in browser. And traceur is the default transpiler in systemjs.\r\n\r\nI presume adding the `# sourceURL` annotation on the traceur path would help."},"comment":{"url":"https://api.github.com/repos/ModuleLoader/es6-module-loader/issues/comments/91064868","html_url":"https://github.com/ModuleLoader/es6-module-loader/issues/355#issuecomment-91064868","issue_url":"https://api.github.com/repos/ModuleLoader/es6-module-loader/issues/355","id":91064868,"user":{"login":"metamatt","id":313893,"avatar_url":"https://avatars.githubusercontent.com/u/313893?v=3","gravatar_id":"","url":"https://api.github.com/users/metamatt","html_url":"https://github.com/metamatt","followers_url":"https://api.github.com/users/metamatt/followers","following_url":"https://api.github.com/users/metamatt/following{/other_user}","gists_url":"https://api.github.com/users/metamatt/gists{/gist_id}","starred_url":"https://api.github.com/users/metamatt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metamatt/subscriptions","organizations_url":"https://api.github.com/users/metamatt/orgs","repos_url":"https://api.github.com/users/metamatt/repos","events_url":"https://api.github.com/users/metamatt/events{/privacy}","received_events_url":"https://api.github.com/users/metamatt/received_events","type":"User","site_admin":false},"created_at":"2015-04-08T23:17:45Z","updated_at":"2015-04-08T23:17:45Z","body":"One more factor here: digging through the transpiled code in the devtools Sources viewer, I see there's already a `# sourceMappingURL` annotation there but it's not at the top level.\r\n\r\nThe module as I defined it is wrapped in 2 layers of `function(){}`, the inner one is the `System.register` callback for dependency resolution, the outer one is an anonymous function of no arguments which I assume is just there to avoid scope pollution. And the `//# sourceMappingURL` annotation is on the inner function. But I believe the `//#` annotations are magic things interpreted by `eval` only at the end of the `eval`'d string, not at function granularity inside the `eval`'d string.\r\n\r\nThat's all to say that something tried to generate a source map and use it, but then something else came along afterwards and wrapped up this nicely labelled payload in another layer of function/closure that hides the annotation. I think.\r\n\r\nThe module.js!eval payload after transpilation looks something like\r\n\r\n```\r\n(function() { var __moduleName = \"s/loader/socket\"; var __moduleAddress = \"http://localhost:1080/s/loader/socket.js\";System.register([], function (_export) {\r\n  var socket;\r\n  return {\r\n    setters: [],\r\n    execute: function () {\r\n      'use strict';\r\n\r\n      // XXX should load socket.io with systemjs instead\r\n      /* global io */\r\n\r\n      socket = io.connect();\r\n\r\n      _export('default', socket);\r\n    }\r\n  };\r\n});\r\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImh0dHA6Ly9sb2NhbGhvc3Q6MTA4MC9zL2xvYWRlci9zb2NrZXQuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtNQUtJLE1BQU07Ozs7QUFMVixrQkFBWSxDQUFDOzs7OztBQUtULFlBQU0sR0FBRyxFQUFFLENBQUMsT0FBTyxFQUFFOzt5QkFFVixNQUFNIiwiZmlsZSI6Imh0dHA6Ly9sb2NhbGhvc3Q6MTA4MC9zL2xvYWRlci9zb2NrZXQuanMiLCJzb3VyY2VzQ29udGVudCI6WyIndXNlIHN0cmljdCc7XG5cbi8vIFhYWCBzaG91bGQgbG9hZCBzb2NrZXQuaW8gd2l0aCBzeXN0ZW1qcyBpbnN0ZWFkXG4vKiBnbG9iYWwgaW8gKi9cblxudmFyIHNvY2tldCA9IGlvLmNvbm5lY3QoKTtcblxuZXhwb3J0IGRlZmF1bHQgc29ja2V0O1xuIl19\r\n }).call(__global);\r\n```\r\n\r\nSo the source map is present but I don't think it's getting used. (This is true of both the traceur and babel paths.)"}}