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.

Consider allowing alternate minifier instead of uglify for better ESNext support

See original GitHub issue

I’m submitting a feature request

  • Library Version: 0.24.0

Please tell us about your environment:

  • Operating System: Windows 10

  • Node Version: 7.50

  • NPM Version: 4.0.5
  • Browser: Chrome 56

  • Language: ESNext

Current behavior: UglifyJS does not support some ESNext features available in babel and current browsers such as Generators and Async Functions.

Both fail with error ‘SyntaxError: Unexpected token operator «*», expected punc «(»’,

Expected/desired behavior: ESNext features supported by babel should also be supported by the aurelia-cli minification process.

To reproduce Add a generator function to your code and run au build --env prod

Possible solutions: If the minification process is extracted to a gulp task then the user can swap out uglify with babili which supports the same features as babel.

Uglify does have a harmony version which has better support for ESNext features but there is a long discussion on which might be better to use moving forward. By extracting to a gulp task it gives the user the ability to choose.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
roducommented, Apr 5, 2018

From my analysis, new projects created with the CLI containing this patch should work out of the box. This is easy to test:

  1. Take a note of the current CLI you are using: au --version just in case you want to reinstall that
  2. Pull down the patch
  3. uninstall your current aurelia-cli (npm uninstall -g aurelia-cli)
  4. Follow the instructions in the README of the CLI project to build the patch version
  5. Make sure to run npm link aurelia-cli in your existing project as the README says
  6. Run your project build as usual and observe how minification completes

I would expect that existing projects can keep the current configuration and build with the new version of the CLI that uses uglify-es with no problems. Unless they were created long ago and have some other kind of incompatibility. Those projects should probably not even bother and keep the CLI they have.

Please note the following

  1. In this change, we are adding the uglify-es dependency to the package.json of the CLI itself. Before, the dependency on the minifier was satisfied via the package.json of the project you generate using the CLI (au new).

Adding the dependency to the CLI package.json, existing projects that have uglify-js in their package.json and upgrade the CLI will be able to build without the need for installing uglify-es first, because the CLI npm install pulls that in.

This also means that future new projects created with this CLI patch will get the uglify-es dependency both from the CLI package.json and then from the project package.json. Surely one is redundant, but this would help smooth the transition for pre-existing projects.

  1. In an alternative to 1, if we change the minifier and don’t add the uglify-es dependency in the CLI package.json, things are more in line with the initial approach where uglify-js was installed via the project dependency after au new. In that case, new projects would be OK, but people would have to manually install uglify-es in their existing projects (i.e.: npm install -D uglify-es) when upgrading the CLI.

I can highlight the situation here, but I would not know what’s the best approach you would like to follow in these cases.

1reaction
delebashcommented, Feb 16, 2017

Yep. It will be awhile before I can really dig in, but as soon as I get the chance I will. Right now just installing the harmony branch of uglify takes care of generators and async. I have only tested with generators and async so I am not sure what other ESNext features uglify-js harmony provides.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Terser vs. Uglify vs. babel-minify: Comparing JavaScript ...
Terser is one of the most popular and efficient libraries for minifying ES6 code. See how Terser compares to UglifyJS and babel-minify.
Read more >
API - esbuild
The build API call operates on one or more files in the file system. This allows the files to reference each other and...
Read more >
babel/preset-env
NOTE: If you require an alternative minifier which does support ES6 syntax, we recommend Terser.
Read more >
Advanced Features: Next.js Compiler
js Compiler, written in Rust using SWC, allows Next.js to transform and minify your JavaScript code for production. This replaces Babel for individual...
Read more >
babel-minify vs terser (instead uglify-js)
Since then, terser has become a good alternative, and performs faster than babel-minify while still supporting ES6 (probably because it's ...
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