Consider allowing alternate minifier instead of uglify for better ESNext support
See original GitHub issueI’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:
- Created 7 years ago
- Comments:11 (4 by maintainers)
From my analysis, new projects created with the CLI containing this patch should work out of the box. This is easy to test:
au --version
just in case you want to reinstall thatnpm uninstall -g aurelia-cli
)npm link aurelia-cli
in your existing project as the README saysI 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
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 theirpackage.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 projectpackage.json
. Surely one is redundant, but this would help smooth the transition for pre-existing projects.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.
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.