Esprima minification problems

Posted on
  • Esprima minification (used in the IDE by default) has a really nasty behavior....

    It removes just about all the linebreaks. So Espruino has to hold the entire blob of code being sent over, and then execute it. I ran into this with Espruino on ESP8266 - as far as I could tell, it was being sent over as one giant blob of commands, with no linebreaks, so Espruino wouldn't process the pieces until it finally got a linebreak (assuming it didn't run out of memory first).

    That's my analysis of it at least. If only there was some way to tell it to put some linebreaks in, like at the end of functions...

    Here's the code that manifests it:

    https://github.com/SpenceKonde/AzzyProje­cts/blob/d739f857b3aedf089acf26d08a4c5a2­4fc9d01a4/Animate/Version5.js

    With Esprima(offline) minification for modules and code, it fails with out of memory errors (often "cannot create string").

    If I change the code minification to closure, it works fine.

  • Interesting - thanks! So for modules it wouldn't be an issue as that happens already, but it's presumably the whole project that causes problems.

    I reckon this could be fixed pretty easily in codeWriter.js in the IDE - after all, it already tweaks newlines of the form function a() [newline] {, so I reckon it could add newlines after each function.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Esprima minification problems

Posted by Avatar for DrAzzy @DrAzzy

Actions