You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • redeclaring a variable existing in an outside scope sure seems fishy.

    Yes... The problem I have is esprima seems more or less unmaintained now - and it's hard to find a decent minifier that can be bundled up and run in the browser and node.js.

    Someone attempted using rollup at one point. but as I remember it was huge and ended up being a bit of a mess to use.

    Does the minifier actually know that Bangle.load can call g.whatever()?

    Oh, I misunderstood.

    That shouldn't actually be a problem. Or was it generating a new global variable of that name?

    If you do:

    function boom() {
      g.reset();
    }
    
    function hello() {
      var g = "blah";
      boom();
    }
    

    or:

    function boom() {
      g.reset();
    }
    
    {
      let g = "blah";
      boom();
    }
    

    Then there should be no problem - the function that uses g will only do it from the global scope, not the local one

  • Regarding another minifier than esprima, have you tried uglifyjs? It is build for Node.js and there are projects using it wrapped for a browser like https://github.com/Skalman/UglifyJS-online. I know close to nothing about the whole NPM/Node world, it's just what I had seen used for minification sometime before.

    As for the minification problem in iconlaunch, I currently can not reproduce that because of changes I have done to iconlaunch since then. Probably because the problematic code now just uses other variable names after minification. I will have an eye on that and try to build a minimum sample if I see it happening again.

About

Avatar for Gordon @Gordon started