Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screenshots in "Why use pump?" don't match actual output #264

Closed
tony19 opened this issue Feb 2, 2017 · 2 comments
Closed

Screenshots in "Why use pump?" don't match actual output #264

tony19 opened this issue Feb 2, 2017 · 2 comments

Comments

@tony19
Copy link

tony19 commented Feb 2, 2017

The screenshot in "Why use pump?" shows neat output (no typical noisy stack traces) that indicate the error message, file, and line number:

pump error

...but it actually looks like the following.

Without pump:

/Users/tony/src/polymer/polymer-typescript-starter-kit/node_modules/gulp-uglify/lib/create-error.js:6
  var perr = new GulpUglifyError(msg, cause);
             ^
GulpUglifyError: unable to minify JavaScript
    at createError (/Users/tony/src/polymer/polymer-typescript-starter-kit/node_modules/gulp-uglify/lib/create-error.js:6:14)
    at wrapper (/Users/tony/src/polymer/polymer-typescript-starter-kit/node_modules/lodash/_createHybrid.js:87:15)
    at trycatch (/Users/tony/src/polymer/polymer-typescript-starter-kit/node_modules/gulp-uglify/minifier.js:26:12)
    at DestroyableTransform.minify [as _transform] (/Users/tony/src/polymer/polymer-typescript-starter-kit/node_modules/gulp-uglify/minifier.js:76:19)
    at DestroyableTransform.Transform._read (/Users/tony/src/polymer/polymer-typescript-starter-kit/node_modules/readable-stream/lib/_stream_transform.js:159:10)
    at DestroyableTransform.Transform._write (/Users/tony/src/polymer/polymer-typescript-starter-kit/node_modules/readable-stream/lib/_stream_transform.js:147:83)
    at doWrite (/Users/tony/src/polymer/polymer-typescript-starter-kit/node_modules/readable-stream/lib/_stream_writable.js:347:64)
    at writeOrBuffer (/Users/tony/src/polymer/polymer-typescript-starter-kit/node_modules/readable-stream/lib/_stream_writable.js:336:5)
    at DestroyableTransform.Writable.write (/Users/tony/src/polymer/polymer-typescript-starter-kit/node_modules/readable-stream/lib/_stream_writable.js:274:11)
    at DestroyableTransform.ondata (/Users/tony/src/polymer/polymer-typescript-starter-kit/node_modules/readable-stream/lib/_stream_readable.js:546:20)

With pump:

GulpUglifyError: unable to minify JavaScript
Caused by: SyntaxError: Unexpected token: name (Foo) (line: 1, col: 6, pos: 6)

Error
    at new JS_Parse_Error (eval at <anonymous> (/Users/tony/src/polymer/polymer-typescript-starter-kit/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:1547:18)
    at js_error (eval at <anonymous> (/Users/tony/src/polymer/polymer-typescript-starter-kit/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:1555:11)
    at croak (eval at <anonymous> (/Users/tony/src/polymer/polymer-typescript-starter-kit/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2094:9)
    at token_error (eval at <anonymous> (/Users/tony/src/polymer/polymer-typescript-starter-kit/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2102:9)
    at unexpected (eval at <anonymous> (/Users/tony/src/polymer/polymer-typescript-starter-kit/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2108:9)
    at semicolon (eval at <anonymous> (/Users/tony/src/polymer/polymer-typescript-starter-kit/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2128:56)
    at simple_statement (eval at <anonymous> (/Users/tony/src/polymer/polymer-typescript-starter-kit/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2319:73)
    at eval (eval at <anonymous> (/Users/tony/src/polymer/polymer-typescript-starter-kit/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2188:19)
    at eval (eval at <anonymous> (/Users/tony/src/polymer/polymer-typescript-starter-kit/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2141:24)
    at eval (eval at <anonymous> (/Users/tony/src/polymer/polymer-typescript-starter-kit/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2909:23)

Line number is given but no source filename, which defeats the utility of the line number. Has the code changed since you made those screenshots? Was that intentionally removed? (And if so, why?) Or is it a pump-config issue?

Note the source that's piped through uglify is ES6 (to cause an error):

class Foo {
  constructor() {
    console.log('hello world');
  }
}

The gulp script for the task:

const gulp = require('gulp');
const pump = require('pump');
const $ = require('gulp-load-plugins')();

gulp.task('tony', (cb: Function) => {
  pump([
      gulp.src('src/**/*.js'),
      $.debug({title: 'tony'}),
      $.uglify(),
      gulp.dest('dist')
    ],
    cb
  );
});

Environment

  • gulp-uglify 2.0.1
  • gulp 3.9.1
  • macOS Sierra 10.12
  • node 7.5.0
@terinjokes
Copy link
Owner

terinjokes commented Feb 3, 2017 via email

@terinjokes
Copy link
Owner

@tony19 To clear up some confusion: the line and column information you had in your error message is embedded within UglifyJS's error string. UglifyJS doesn't really know about more than one file at a time, thus why it doesn't include the filename in the error.

I failed to correct the error string (to add our own file and line information) when we moved to a new error wrapper in v2.0.0. This has now been corrected in v2.1.1.

The screenshots still don't exactly match, but the same information is now contained.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants