Better handle ES6 source
See original GitHub issueExpected 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:
- Created 6 years ago
- Comments:8 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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!
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.
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.