Skip to content

Instantly share code, notes, and snippets.

@myrne
Forked from anonymous/compiled.js
Created August 22, 2013 18:17
Show Gist options
  • Save myrne/6310841 to your computer and use it in GitHub Desktop.
Save myrne/6310841 to your computer and use it in GitHub Desktop.
Source map does work when serving these files over HTTP (or HTTPS). It doesn't work when loading them directly from disk (using `file://`).
// Generated by CommonJS Everywhere 0.9.2
(function (global) {
function require(file, parentModule) {
if ({}.hasOwnProperty.call(require.cache, file))
return require.cache[file];
var resolved = require.resolve(file);
if (!resolved)
throw new Error('Failed to resolve module ' + file);
var module$ = {
id: file,
require: require,
filename: file,
exports: {},
loaded: false,
parent: parentModule,
children: []
};
if (parentModule)
parentModule.children.push(module$);
var dirname = file.slice(0, file.lastIndexOf('/') + 1);
require.cache[file] = module$.exports;
resolved.call(module$.exports, module$, module$.exports, dirname, file);
module$.loaded = true;
return require.cache[file] = module$.exports;
}
require.modules = {};
require.cache = {};
require.resolve = function (file) {
return {}.hasOwnProperty.call(require.modules, file) ? require.modules[file] : void 0;
};
require.define = function (file, fn) {
require.modules[file] = fn;
};
var process = function () {
var cwd = '/';
return {
title: 'browser',
version: 'v0.10.10',
browser: true,
env: {},
argv: [],
nextTick: global.setImmediate || function (fn) {
setTimeout(fn, 0);
},
cwd: function () {
return cwd;
},
chdir: function (dir) {
cwd = dir;
}
};
}();
require.define('/script.coffee', function (module, exports, __dirname, __filename) {
throw new Error('some error');
});
require('/script.coffee');
}.call(this, this));
//# sourceMappingURL=compiled.map
{"version":3,"sources":["/script.coffee"],"names":["Error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAA,MAAM,IAAIA,KAAJ,CAAU,YAAV,CAAN,C","sourceRoot":".","sourcesContent":["throw new Error \"some error\""]}
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript" src="compiled.js"></script>
</head>
<body></body>
</html>
throw new Error "some error"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment