source-map-support
Advanced tools
Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "source-map-support", | ||
"version": "0.1.0", | ||
"description": "Fixes stack traces for files with source maps", | ||
"version": "0.1.1", | ||
"main": "./source-map-support.js", | ||
@@ -5,0 +6,0 @@ "scripts": { |
# Source Map Support | ||
This module provides source map support for stack traces in node via the [V8 stack trace API](http://code.google.com/p/v8/wiki/JavaScriptStackTraceApi). It uses the [source-map](https://github.com/mozilla/source-map) module to replace the paths and line numbers of source-mapped files with their original paths and line numbers. The output mimics node's stack trace format with the goal of making every compile-to-JS language more of a first-class citizen. This module takes effect globally and should be initialized by inserting a call to require('source-map-support') at the top of your code. | ||
This module provides source map support for stack traces in node via the [V8 stack trace API](http://code.google.com/p/v8/wiki/JavaScriptStackTraceApi). It uses the [source-map](https://github.com/mozilla/source-map) module to replace the paths and line numbers of source-mapped files with their original paths and line numbers. The output mimics node's stack trace format with the goal of making every compile-to-JS language more of a first-class citizen. Source maps are completely general (not specific to any one language) so you can use source maps with multiple compile-to-JS languages in the same node process. | ||
### Installation | ||
npm install source-map-support | ||
This module takes effect globally and should be initialized by inserting a call to `require('source-map-support')` at the top of your code. | ||
### CoffeeScript Demo | ||
@@ -40,2 +46,4 @@ | ||
Note that the steps above are just to demonstrate this library. If you want good stack traces for your own CoffeeScript project, you can run coffee files directly with CoffeeScriptRedux (use the `--eval` flag) and the stack traces will have the correct CoffeeScript line numbers. | ||
### TypeScript Demo | ||
@@ -42,0 +50,0 @@ |
@@ -10,3 +10,3 @@ var SourceMapConsumer = require('source-map').SourceMapConsumer; | ||
var fileData = fs.readFileSync(position.source, 'utf8'); | ||
var match = /\/\/@\s*sourceMappingURL=(.*)\s*$/.exec(fileData); | ||
var match = /\/\/@\s*sourceMappingURL=(.*)\s*$/m.exec(fileData); | ||
if (!match) return position; | ||
@@ -13,0 +13,0 @@ var sourceMappingURL = match[1]; |
11601
83