evanw / node-source-map-support

Adds source map support to node.js (for stack traces)
MIT License
2.16k stars 223 forks source link

Could multiple lines added to the generated code throw this off? #103

Open jedwards1211 opened 8 years ago

jedwards1211 commented 8 years ago

I'm inserting multiple lines at the top of a Webpack bundle for the sake of making this work when I load the bundle in Meteor, like so:

require("source-map-support/register");
var Npm = Meteor.__mwrContext__.Npm;
var Assets = Meteor.__mwrContext__.Assets;
delete Meteor.__mwrContext__;
var require = Npm.require;

/******/ (function(modules) { // webpackBootstrap

The other lines are hacks that allow me to require the bundle (Meteor normally loads all server files via vm.callInThisContext. I assume that source-map-support-will only work if the file is required in as a module like this (if there's another way, let me know).

However one of my users reported the following error https://github.com/jedwards1211/meteor-webpack-react/issues/86:

/node_modules/source-map-support/node_modules/source-map/lib/source-map/source-map-consumer.js:281
W20151007-12:26:26.964(-4)? (STDERR) throw new TypeError('Column must be greater than or equal to 0, got '
W20151007-12:26:26.964(-4)? (STDERR) ^
W20151007-12:26:26.964(-4)? (STDERR) TypeError: Column must be greater than or equal to 0, got -23
W20151007-12:26:26.964(-4)? (STDERR) at SourceMapConsumer_findMapping as _findMapping

Could this be caused by the extra lines I added to the top of the bundle? I've read some about how source maps work, but I think you would be more prepared to answer this question than me. Thanks!

jeffschmitz commented 8 years ago

Did you ever get resolution on this? I'm seeing the same error now.

jedwards1211 commented 8 years ago

No, I stopped loading source-map-support/register with a Webpack banner and just put it in the Webpack entry instead, and I'm not having issues anymore

basarat commented 8 years ago

I am getting the same error but with ts-node + mocha:

MOCHA STDERR: D:\REPOS\alm\node_modules\source-map-support\source-map-support.js:411
      var hasStack = (arguments[1] && arguments[1].stack);
                                                  ^

TypeError: Column must be greater than or equal to 0, got -62
    at SourceMapConsumer_findMapping [as _findMapping] (D:\REPOS\alm\node_modules\source-map-support\node_modules\source-map\lib\source-map\source-map-consumer.js:281:15)
    at SourceMapConsumer_originalPositionFor [as originalPositionFor] (D:\REPOS\alm\node_modules\source-map-support\node_modules\source-map\lib\source-map\source-map-consumer.js:310:26)
    at mapSourcePosition (D:\REPOS\alm\node_modules\source-map-support\source-map-support.js:188:42)
    at wrapCallSite (D:\REPOS\alm\node_modules\source-map-support\source-map-support.js:327:20)
    at D:\REPOS\alm\node_modules\source-map-support\source-map-support.js:362:26
    at Array.map (native)
    at Function.prepareStackTrace (D:\REPOS\alm\node_modules\source-map-support\source-map-support.js:361:24)
    at process.emit (D:\REPOS\alm\node_modules\source-map-support\source-map-support.js:411:51)
    at process._fatalException (node.js:237:26)