Chris2011 / minifierbeans

Plugin to minify JS , CSS and HTML for quicken page load times by reducing the size of js/css/html files.
http://plugins.netbeans.org/plugin/49666/js-css-minify-compress
Apache License 2.0
37 stars 9 forks source link

ES6 Class isn't minified. #32

Closed hkaraoglu closed 6 years ago

hkaraoglu commented 6 years ago

If there is an ES6 class in javascript file. It isn't minified. The plugin just creates an empty file.

Example code:

class Polygon {
  // ..and an (optional) custom class constructor. If one is
  // not supplied, a default constructor is used instead:
  // constructor() { }
  constructor(height, width) {
    this.name = 'Polygon';
    this.height = height;
    this.width = width;
  }

  // Simple class instance methods using short-hand method
  // declaration
  sayName() {
    ChromeSamples.log('Hi, I am a ', this.name + '.');
  }

  sayHistory() {
    ChromeSamples.log('"Polygon" is derived from the Greek polus (many) ' +
      'and gonia (angle).');
  }

  // We will look at static and subclassed methods shortly
}

Output:

Empty file.

Chris2011 commented 6 years ago

Hi, thx for the report. Please read my readme from the Headline Attention. This plugin uses yuicompressor and unfortunately it is not supporting ES6. Thx

Chris2011 commented 6 years ago

Duplicate of #3

jGauravGupta commented 6 years ago

Possibly yuicompressor can be replaced with ES6 supported compressor.

Chris2011 commented 6 years ago

yes I thought so too but unfortunately this is not on prio list :/

hkaraoglu commented 6 years ago

At least, this issue can be solved by creating an output file is as same as input file instead of empty file.

Chris2011 commented 6 years ago

As an easy workaround and a message, what happens there. To create the same output after minifing is confusing, the same as the current behaviour. So a little message like: There where errors, we can't minified it, would be better and to generate the file anyway or not. With an option. But as I said, this could be the workaround for this.

The better solution, maybe for an other ticket is to get rid of the YUI Compressor and use a updated one, like the google closure compiler or what we have.

hkaraoglu commented 6 years ago

The plugin doesn't support JS ES6 classes.So this issue is fixed by creating same output file if a file is cannot be minified. (Workaround.) ES6 support will be handled in other issue.