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.

optimize: true breaks es6 compatibility

See original GitHub issue

Steps to reproduce:

  1. Create a blank project using bankai

  2. For your client.js code, simply add the following lines:


var foo = `bar`
var func = (args) => console.log

Expected results Should be no error

Actual results the node instance blows up and appears that uglifyjs is parsing with es5 rules.

some notes/findings: Using babelify, es2020 do not work

When trying to use those as transforms in package.json or passed into browserify using the js property you get another error stating that the path to client.js cannot be found. If you disable yoyoify you then get the same damn uglifyjs error anyway. I think that the transforms might not be called in the correct order, but I am not sure.

yoyoify transpiles backticks if you use them with bel/yo/choo - Optimize will not fail if you are using template tag strings that are passed in to bel/yo/choo - but that is the only case. using fat arrow functions though will not work at all.

Suggested fix Let developers overload js or optimize and have the ability to explicitly use different transforms when optimize is true. this could be messy but this would add some flexibility.

Or maybe ditch the uglifyjs transform all together and just pipe the finished browserify stream to uglifyjs when everything is done?? idk if that will work but right now I’m just not sure how to get this to work other than to use es5 only which makes me sad.

See also: https://github.com/mishoo/UglifyJS2/issues/1411

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
rahatarmanahmedcommented, Feb 4, 2017

The workaround for this, as @yoshuawuyts says, is to have duplicate yoyoify and sheetify transforms before babelify. Not ideal but it seems to work.

const jsOpts = {
  js: {
    transform: [
      'envify',
      'sheetify/transform',
      'yo-yoify',
      ['babelify', { presets: ['latest'] }]
    ]
  },
  optimize: true
}
const clientPath = path.join(__dirname, '../client/app.js')
client = bankai(clientPath, jsOpts)
0reactions
yoshuawuytscommented, Apr 22, 2017

You can now do --uglify false and it should no longer crash, can just pull in your own uglify (: Given the lack of activity I think this issue has been resolved. Feel free to reopen if it hasn’t been. Cheers!

Read more comments on GitHub >

github_iconTop Results From Across the Web

ECMAScript 6 compatibility table
Feature name▻ Current browser 98% ES6 Trans‑ piler 25% Trace... Optimisation Optimisation Optimisation Optimi... §proper tail calls (tail call optimisation)▻ 0/2 0/2 0/2 §direct recursionc No...
Read more >
The ES6 Conundrum - SitePoint
The problem with ES6 is that it breaks backwards compatibility as it introduces many syntax changes to JavaScript instead of just new methods ......
Read more >
"es6" | Can I use... Support tables for HTML5, CSS3, etc
As ES6 refers to a huge specification and browsers have various levels of support, "Supported" means at least 95% of the spec is...
Read more >
ES6 Tail Recursion Optimisation Stack Overflow
TCO support seems to have reached a decent level in V8 at one point, but remained behind a flag for several reasons (debugging...
Read more >
ES6 features you can use with Vue now
A tour of all the essential ES6 features you can use in your Vue apps now (with IE 11 supports)
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