dougwilson / nodejs-depd

Deprecate all the things
MIT License
325 stars 87 forks source link

Not working with firefox ? #14

Closed Poil closed 9 years ago

Poil commented 9 years ago

Hi,

I've opened a but on puppetexplorer but it seem the bug came from your module (I'm a noob in nodejs so perhaps I'm totally wrong)

I've got this error in Firefox "TypeError: Error.captureStackTrace is not a function"

If you check other nodejs module you have acode like this

  if (Error.captureStackTrace) {
    Error.captureStackTrace(this, stackStartFunction);
  }
  else {
    // non v8 browsers so we can have a stacktrace
    var err = new Error();
    if (err.stack) {
      var out = err.stack;

      // try to strip useless frames
      var fn_name = stackStartFunction.name;
      var idx = out.indexOf('\n' + fn_name);
      if (idx >= 0) {
        // once we have located the function frame
        // we need to strip out everything before it (and its line)
        var next_line = out.indexOf('\n', idx + 1);
        out = out.substring(next_line + 1);
      }

      this.stack = out;
    }
  }
dougwilson commented 9 years ago

Hi! This is a Node.js module; it is not intended to function within web browsers. According to your stack from the other issue, the ast-types module, if it intends to function within a web browser, should define a fallback for it's dependency on this module when used within things like browserify.