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

Random minified JavaScript code added to file on save #74

Closed JuergenLaas closed 3 years ago

JuergenLaas commented 3 years ago

If I install Minifierbeans-3.3.0 in Netbeans 12.3 and set checkbox to "Minify on Save" in Settings. Modify my JavaScript file and save it, a new JavaScript file is created with extension ".min.js". In this file an additional JavaScript code is inserted at the beginning of the file. This code is not from me and is inserted automatically at the beginning of the file each time.

Here an Example of this Code:

var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;$jscomp.ISOLATE_POLYFILLS=!1;$jscomp.FORCE_POLYFILL_PROMISE=!1;$jscomp.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(b,c,d){if(b==Array.prototype||b==Object.prototype)return b;b[c]=d.value;return b}; $jscomp.getGlobal=function(b){b=["object"==typeof globalThis&&globalThis,b,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var c=0;c<b.length;++c){var d=b[c];if(d&&d.Math==Math)return d}throw Error("Cannot find global object");};$jscomp.global=$jscomp.getGlobal(this);$jscomp.IS_SYMBOL_NATIVE="function"===typeof Symbol&&"symbol"===typeof Symbol("x");$jscomp.TRUST_ES6_POLYFILLS=!$jscomp.ISOLATE_POLYFILLS||$jscomp.IS_SYMBOL_NATIVE;$jscomp.polyfills={}; $jscomp.propertyToPolyfillSymbol={};$jscomp.POLYFILL_PREFIX="$jscp$";var $jscomp$lookupPolyfilledValue=function(b,c){var d=$jscomp.propertyToPolyfillSymbol[c];if(null==d)return b[c];d=b[d];return void 0!==d?d:b[c]};$jscomp.polyfill=function(b,c,d,f){c&&($jscomp.ISOLATE_POLYFILLS?$jscomp.polyfillIsolated(b,c,d,f):$jscomp.polyfillUnisolated(b,c,d,f))}; $jscomp.polyfillUnisolated=function(b,c,d,f){d=$jscomp.global;b=b.split(".");for(f=0;f<b.length-1;f++){var e=b[f];if(!(e in d))return;d=d[e]}b=b[b.length-1];f=d[b];c=c(f);c!=f&&null!=c&&$jscomp.defineProperty(d,b,{configurable:!0,writable:!0,value:c})}; $jscomp.polyfillIsolated=function(b,c,d,f){var e=b.split(".");b=1===e.length;f=e[0];f=!b&&f in $jscomp.polyfills?$jscomp.polyfills:$jscomp.global;for(var g=0;g<e.length-1;g++){var k=e[g];if(!(k in f))return;f=f[k]}e=e[e.length-1];d=$jscomp.IS_SYMBOL_NATIVE&&"es6"===d?f[e]:null;c=c(d);null!=c&&(b?$jscomp.defineProperty($jscomp.polyfills,e,{configurable:!0,writable:!0,value:c}):c!==d&&($jscomp.propertyToPolyfillSymbol[e]=$jscomp.IS_SYMBOL_NATIVE?$jscomp.global.Symbol(e):$jscomp.POLYFILL_PREFIX+e,e= $jscomp.propertyToPolyfillSymbol[e],$jscomp.defineProperty(f,e,{configurable:!0,writable:!0,value:c})))};$jscomp.polyfill("Object.is",function(b){return b?b:function(c,d){return c===d?0!==c||1/c===1/d:c!==c&&d!==d}},"es6","es3");$jscomp.polyfill("Array.prototype.includes",function(b){return b?b:function(c,d){var f=this;f instanceof String&&(f=String(f));var e=f.length;d=d||0;for(0>d&&(d=Math.max(d+e,0));d<e;d++){var g=f[d];if(g===c||Object.is(g,c))return!0}return!1}},"es7","es3"); $jscomp.checkStringArgs=function(b,c,d){if(null==b)throw new TypeError("The 'this' value for String.prototype."+d+" must not be null or undefined");if(c instanceof RegExp)throw new TypeError("First argument to String.prototype."+d+" must not be a regular expression");return b+""};$jscomp.polyfill("String.prototype.includes",function(b){return b?b:function(c,d){return-1!==$jscomp.checkStringArgs(this,c,"includes").indexOf(c,d||0)}},"es6","es3")

after this Code i see my code.

Chris2011 commented 3 years ago

Please use more informative headlines next time. Also it would be good to add a sample project where this happens.

Chris2011 commented 3 years ago

Ok sample project is not needed, I can reproduce this. Thx for report.

Chris2011 commented 3 years ago

This is coming from the CLI command: --language_out STABLE, I change it to: ECMASCRIPT_2016 and it looks better. Please see here for more information: ECMASCRIPT_2016. I will change the option to a newer one. I think the code is a polyfill for older ES versions. My code, which produces this code was const test = Object.assign({});

Chris2011 commented 3 years ago

Closing this, will be handled here: https://github.com/Chris2011/minifierbeans/issues/75