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

Unexpected token => #95

Open
ledsun opened this issue Aug 4, 2017 · 3 comments
Open

Unexpected token => #95

ledsun opened this issue Aug 4, 2017 · 3 comments

Comments

@ledsun
Copy link

ledsun commented Aug 4, 2017

Error information

I found a parse error when I convert the next code by the gulp-browserify.

const {
  EventEmitter
} = require('events')
const em = new EventEmitter()

em.on('data', ({
    one,
    two
  }) => console.log(one + two))
em.emit('data', {one: 1, two: 2})

The error messages are:

npx gulp browserify                                                                                                                                                          ~/test
[16:32:19] Using gulpfile ~/test/gulpfile.js
[16:32:19] Starting 'browserify'...

events.js:182
      throw er; // Unhandled 'error' event
      ^
Error: Parsing file /Users/shigerunakajima/test/fake_acd2fc2c.js: Line 9: Unexpected token =>
    at Deps.parseDeps (/Users/shigerunakajima/test/node_modules/module-deps/index.js:339:28)
    at /Users/shigerunakajima/test/node_modules/module-deps/index.js:261:37
    at ConcatStream.<anonymous> (/Users/shigerunakajima/test/node_modules/concat-stream/index.js:36:43)
    at emitNone (events.js:110:20)
    at ConcatStream.emit (events.js:207:7)
    at finishMaybe (/Users/shigerunakajima/test/node_modules/readable-stream/lib/_stream_writable.js:460:14)
    at endWritable (/Users/shigerunakajima/test/node_modules/readable-stream/lib/_stream_writable.js:469:3)
    at ConcatStream.Writable.end (/Users/shigerunakajima/test/node_modules/readable-stream/lib/_stream_writable.js:436:5)
    at DuplexWrapper.onend (/Users/shigerunakajima/test/node_modules/readable-stream/lib/_stream_readable.js:537:10)
    at Object.onceWrapper (events.js:314:30)

Run this code on the node v8.2.1 and it succeeds.

node index.js
=> 3

And the browserify v14.4.0 can convert this code.

To reproduce

gulpfile.js

const gulp = require('gulp')
const browserify = require('gulp-browserify')

gulp
  .task('browserify', () => gulp
    .src(['index.js'])
    .pipe(browserify({debug: true}))
    .pipe(gulp.dest('dist'))
  )

package.json

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "MIT",
  "dependencies": {
    "gulp": "^3.9.1",
    "gulp-browserify": "^0.5.1"
  }
}
@anfedorov
Copy link

Can confirm this happens with

  "version": "0.5.1",
  "resolved": "https://registry.npmjs.org/gulp-browserify/-/gulp-browserify-0.5.1.tgz",
  "integrity": "sha1-ggEIrCVUqVStuL4X0jlYsMBL4IM=",
  "dev": true,
  "requires": {
    "browserify": "3.46.1",
    "browserify-shim": "2.0.10",
    "gulp-util": "2.2.20",
    "readable-stream": "1.1.14",
    "through2": "0.4.2"
  },

and node 8.9.0 and 8.2.1 as well. very frustrating!

@anfedorov
Copy link

oh

NOTE: THIS PLUGIN IS NO LONGER MAINTAINED , checkout gulp-bro for a similar plugin, or the recipes by gulp team for reference on using browserify with gulp.

@zpmorgan
Copy link

This confused the crap out of me too, except it left a very unhelpful esprima backtrace. Shoulda checked the versions.

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

3 participants