Skip to content

Commit

Permalink
source maps attempt v1
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Mar 19, 2013
1 parent d5732e0 commit fe1fbbc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
8 changes: 6 additions & 2 deletions coffee-script.js

Large diffs are not rendered by default.

22 changes: 13 additions & 9 deletions cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,27 +126,31 @@ define(['coffee-script'], function (CoffeeScript) {
var path = parentRequire.toUrl(name + '.coffee');
fetchText(path, function (text) {

config.CoffeeScript = config.CoffeeScript || {};
config.CoffeeScript.sourceMap = true;
config.CoffeeScript.sourceFiles = [path];

var compiled;

//Do CoffeeScript transform.
try {
text = CoffeeScript.compile(text, config.CoffeeScript);
compiled = CoffeeScript.compile(text, config.CoffeeScript);
} catch (err) {
err.message = "In " + path + ", " + err.message;
throw err;
}

console.log(compiled);

//Add in the source map if supported
if (window.btoa)
text = compiled.js + '\n//@ sourceMappingURL=data:application/json;base64,' + btoa(compiled.v3SourceMap) + ',\n//@ sourceURL=' + path;

//Hold on to the transformed text if a build.
if (config.isBuild) {
buildMap[name] = text;
}

//IE with conditional comments on cannot handle the
//sourceURL trick, so skip it if enabled.
/*@if (@_jscript) @else @*/
if (!config.isBuild) {
text += "\r\n//@ sourceURL=" + path;
}
/*@end@*/

load.fromText(name, text);

//Give result to load. Need to wait until the module
Expand Down

0 comments on commit fe1fbbc

Please sign in to comment.