question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Better handle ES6 source

See original GitHub issue

Expected behavior

bankai start, bankai build, and bankai inspect work with ES6, or produce actionable error messages.

Actual behavior

When handling ES6 source, bankai start fails with:

SyntaxError: Invalid assignment while parsing file: /Users/seththompson/code/readrc/viewer/test/index.js
    at JS_Parse_Error.get (eval at <anonymous> (/Users/seththompson/.homebrew/lib/node_modules/bankai/node_modules/uglify-js/tools/node.js:27:1), <anonymous>:86:23)

bankai build fails with:

11:23:12 🚨  bankai Invalid assignment while parsing file: /Users/seththompson/code/readrc/viewer/test/index.js

and bankai inspect fails with:

TypeError: Cannot read property 'apply' of undefined
    at Stream.method [as destroy] (/Users/seththompson/.homebrew/lib/node_modules/bankai/node_modules/duplexer/index.js:47:38)
    at /Users/seththompson/.homebrew/lib/node_modules/bankai/node_modules/pump/index.js:43:45
    at call (/Users/seththompson/.homebrew/lib/node_modules/bankai/node_modules/pump/index.js:50:3)
    at Array.forEach (native)
    at /Users/seththompson/.homebrew/lib/node_modules/bankai/node_modules/pump/index.js:70:25
    at f (/Users/seththompson/.homebrew/lib/node_modules/bankai/node_modules/once/once.js:25:25)
    at PassThrough.<anonymous> (/Users/seththompson/.homebrew/lib/node_modules/bankai/node_modules/pump/index.js:29:21)
    at PassThrough.f (/Users/seththompson/.homebrew/lib/node_modules/bankai/node_modules/once/once.js:25:25)
    at emitOne (events.js:96:13)
    at PassThrough.emit (events.js:191:7)

Steps to reproduce behavior

Use bankai on files with ES6 source, for example an index.js:

const choo = require('choo')
const html = require('choo/html')

var app = choo();
app.route('/', (state, emit) => {
  return html`<body><h1>Hello World</h1></body>`
})
app.mount('body')

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
yoshuawuytscommented, Apr 24, 2017

Yeah, I traced this to uglify, it just seems that Bankai should have better error messages if it’s going to enable uglify by default.

I’m open for better error messages. Right now I have no idea how other people are using Bankai, and where it breaks down. I’m all ears for feedback; PR very welcome here!


Also, disc doesn’t handle ES6+ either

It unpacks the bundle that browserify gives it, there shouldn’t be any parsing going on outside of browserify. Not sure what the root cause is tho, but yeah I hope this will help you somewhat on your way.

1reaction
s3ththompsoncommented, Apr 24, 2017

Yeah, I traced this to uglify, it just seems that Bankai should have better error messages if it’s going to enable uglify by default.

My app broke upgrading to 7.5.0 and it took me a while to figure it out.

Also, disc doesn’t handle ES6+ either, so it might be good to call out inspect not working with ES6+ in the repo as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Practical guide to ES6 modules - freeCodeCamp
In this article, we'll create a simple dashboard using ES6 modules, and then present optimization techniques for improving the folder ...
Read more >
ES6 In Depth: Modules - the Web developer blog
ES6 In Depth is a series on new features being added to the JavaScript programming language in the 6th Edition of the ECMAScript...
Read more >
GitHub - rse/es6-features: ECMAScript 6
This is the source of the website es6-features.org, a small overview of current ECMAScript 6 language features and a comparison to their old...
Read more >
16. Modules - Exploring JS
As explained in more detail later, the structure of ES6 modules is static, ... Let's see how CommonJS and ECMAScript 6 handle cyclic...
Read more >
javascript - How will browsers handle ES6 import/export syntax
That means that the script is parsed and handled per the Module ... at the import declarations in the source code, an implementation...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found