Skip to content

Commit

Permalink
Remove Harmony mode from README, recommend terser
Browse files Browse the repository at this point in the history
Harmony mode is not up-to-date in UglifyJS, and more likely to cause issues. Recommend ruby-terser as an alternative.
  • Loading branch information
lautis committed Jan 1, 2021
1 parent d6588bc commit 902cc16
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,7 @@
Ruby wrapper for [UglifyJS](https://github.com/mishoo/UglifyJS2) JavaScript
compressor.

UglifyJS currently is extensively tested with ES5, but also includes experimental ES6/ES2015+/Harmony support.

More stable alternatives for working with ES6 code is to first transpile to ES5 with e.g. [babel-transpiler](https://github.com/babel/ruby-babel-transpiler) or using [Closure Compiler](https://github.com/documentcloud/closure-compiler) to directly minify ES6 code.

## ES6 / ES2015+ / Harmony mode

When using Uglifier with ES6 syntax without any options, an error will be
thrown.

```
Uglifier::Error: Unexpected token: punc ((). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true).
```

The experimental ES6 syntax support can be enabled by passing `:harmony => true`
option to Uglifier.

```ruby
Uglifier.compile(js, harmony: true)
```
UglifyJS only works with ES5. If you need to compress ES6, [ruby-terser](https://github.com/ahorek/terser-ruby) is a better option.

### Rails

Expand Down

1 comment on commit 902cc16

@RogerE
Copy link

@RogerE RogerE commented on 902cc16 Feb 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the Rails section below also have been removed? Seems like the instruction there are related to Harmony mode.

Please sign in to comment.