coderaiser/minify

"use strict"; removed from begining

franck-paul opened this issue · 3 comments

Since release 10.0 the "use strict"; directive is removed from minified version of a js script.

Is it normal and how can we prevent this?

/*global $ */
'use strict';

(() => {
  class debugClass {
    field = null;

    constructor() {
      this.debug = true;
    }

    dump() {
      console.log(this.debug);
    }
  }
  debugClass.prototype.context = 'debug';

  const debug = new debugClass();
  console.log(JSON.stringify(debug));
  console.log(debug.context);
})();

Is now minified to:

(()=>{class debugClass {field=null;constructor() {this.debug = !0;}dump() {console.log(this.debug);}}debugClass.prototype.context = 'debug';var debug=new debugClass();console.log(JSON.stringify(debug));console.log(debug.context);})()

It wasn't the case before the 10.0 release.

Yes it made for minification purpose, why do you want to keep 'use strict' in minified bundle? It should be inside function body to work anyways.

Just get back old behavior with use strict. Please re-install minify. Is it works for you?

Nice! Thank's a lot, it works as expected (for me) ;-)