• Instead of local Web Server, you can also mount an SD card with your modules and require the module from there. To avoid require to be resolved by the upload, you have to put the module name into a variable and use the variable in the require.

    var mn = "moduleName", moduleNameModule = require(mn);
    

    ...even this may work - since a regex is used to search for modules, such as 'require("moduleName") ':

    var mn; // define module name variable once at the beginning of the code
    // .....
    // ...
    // .
    var moduleNameModule = require(mn="moduleName");
    // .....
    // ...
    // .
    var moduleName2Module = require(mn="moduleName2");
    // .....
    // ...
    // .
    

    Using that approach let's you quickly update all your devices by just replacing the SD card... The code that you upload to Espruino is just a boot strapper that mounts the SD card, makes the initial require for the initial module - like a main / init module - and invokes the startup method.

    Of course, the is one more piece of hardware you need per Espruino... but since you go modules, why not to it all the way with modules...

    To make sure the that things work as expected, you need to put the boot strapper code into the onInit() method.

  • Thanks for the suggestion, @allObjects! For some reason, the intermittent load issue has abated, I haven't seen it in the last couple hundred uploads. I haven't shrunken the file size, but I'm also not growing it either.

About