• Bummer? ... no sure about that.

    There is reading of the (nested) requires ahead of time... but it is followed up differently. Compiling (or composing) to a single code entity ...nope... nor 'jit compiling' or a-like, even though there is a "compiled" option and "pre-tokenizing" available. Espruino runs on the source! ...there is just not enough memory for such things. That makes it so unique, and interestingly fast in it's own way (of course it depends on the code to execute.

    There is though a way to keep these js outside of the modules folder and 'somewhat within' the project codes folder: use the repository url in the require... that will pull it from (just any) url... and if you need the require multiple time but the url is long and you want to save the space, keep the module reference in a variable placing something like this in the beginning of the code:

    var aMod = require("https:aVery/Long/Repos/URL/for/­Module/a"), // a=LEDServer
        bMod = require("https:aVery/Long/Repos/URL/for/­Module/b"); // b=warningGif
    

    or - when a and b are actually 'classes'/Constructor functions A and B:

    var A = require("https:aVery/Long/Repos/URL/for/­Class/A"),
        B = require("https:aVery/Long/Repos/URL/for/­Class/B");
    

    This makes sure that the module/'Class'/prototype is load into the Modules cache. Instead of Repos, you may have Web server where you put the stuff... (can even be a Dev Web Server for Code in your (W)LAN (it has to be accessible just at code upload time).

    Later on, you just uses, for example, aMod.<method>(...) - or when classes - var a1 = new A(...); to get what you want.

    This approach though requires that you commit - push to remote - this code ahead of the other code and your repos is publicly accessible our you manage something with cert registration/exchange for authentication under the hood (you can of course always go and modify the Web IDE (and extend the upload capabilities).

    Forgot to mention the multi-step-upload or composing upload: disable/un-check "Reset before upload of code" in Settings-Communications and upload multiple code entities. First you upload these project related modules with above mentioned code snippets. You have though to do a manual reset() in the terminal before the multi-step-upload and load one after the other code entities into the Web IDE editor...

About

Avatar for allObjects @allObjects started