rapydscript-ng icon indicating copy to clipboard operation
rapydscript-ng copied to clipboard

uglify option broken

Open kakaroto opened this issue 5 years ago • 2 comments

If using the -u option, the output is broken. I didn't check it all but there's a few places where a semicolon is missing between statements.

**To reproduce ** :

$ rapydscript --version
rapydscript-ng 0.7.19

$ rapydscript  <(echo 'print("Hello world")') | node
Hello world

$ rapydscript -u  <(echo 'print("Hello world")') | node
[stdin]:1
(function(){"use strict";var ρσ_iterator_symbol=(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol")?Symbol.iterator:"iterator-Symbol-5d0927e5554349048cf0e3762a228256";var ρσ_kwargs_symbol=(typeof Symbol==="function")?Symbol("kwargs-object"):"kwargs-object-Symbol-5d0927e5554349048cf0e3762a228256";var ρσ_cond_temp,ρσ_expr_temp,ρσ_last_exception;var ρσ_object_counter=0;var ρσ_len;function ρσ_bool(val){return!!val};if(!ρσ_bool.__argnames__)Object.defineProperties(ρσ_bool,{__argnames__:{value:["val"]}});function ρσ_print(){var parts;if(typeof console==="object"){parts=[];for(var i = 0; i < arguments.length; i++){parts.push(ρσ_str(arguments[(typeof i==="number"&&i<0)?arguments.length+i:i]))}console.log(parts.join(" "))}};function ρσ_int(val,base){var ans;if(typeof val==="number"){ans=val|0}else{ans=parseInt(val,base||10)}if(isNaN(ans)){throw new ValueError("Invalid literal for int with base "+(base||10)+": "+val)}return ans};if(!ρσ_int.__argnames__)Object.definePr

SyntaxError: Unexpected identifier
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Object.<anonymous> ([stdin]-wrapper:6:22)
    at Module._compile (module.js:652:30)
    at evalScript (bootstrap_node.js:466:27)
    at Socket.<anonymous> (bootstrap_node.js:237:15)
    at emitNone (events.js:111:20)
    at Socket.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)

In the resulting file, I see this for example : hasattr = ρσ_hasattrfunction and

    Object.defineProperty(ZeroDivisionError.prototype, "__bases__", {
        value: [Exception]
    }) var ρσ_in, ρσ_desugar_kwargs, ρσ_exists;

kakaroto avatar Jun 15 '19 06:06 kakaroto

Well, this option is a bit of a hack, inherited from the original rapydscript. I recommend not using it and instead passing the js through any ordinary JS minifier. I'll look into this if a day ever comes when I have nothing better to do, but dont hold your breath

kovidgoyal avatar Jun 15 '19 07:06 kovidgoyal

Ok thanks. I've tried yuicompressor but it has issues with the js because of reserved words being used. I'll see if I can find another one.

kakaroto avatar Jun 15 '19 10:06 kakaroto