• No need to bundle, since at runtime 'nothing' happens, and you gain nothing but the extra step of bundling... or worse, manage the compound export yourself:

    On upload, the IDE goes through the files - recursively - looking (w/ reg expression) for require("moduleName") and upload the files first. And as @Wilberforce points out, does minification if configured to do so... Just make sure you do that not too too too often using Google's minifier - if Espruino still goes that route if configured so - because I got burned with temporary being blocked from Google minification/closure compile service... due to ...overuse of the free option... [Google]

    My approach is now to develop modules by modules inline (similar to what you see in these conversations A and B), and when a module is stable enough, minify it w/ Google's minifier / closure compiler and put it minified into my modules in the local sandbox. Minifying is not just speed, but more so it is space and to provide more variables, since all (most of the time) happens in RAM (yes you can upload into FLASH directly and leaves you with even more RAM for variables...).

    Btw, if you miss multi-document UI in Espruino IDE, edit just your 'main' in Espruino IDE and your modules in your favorite multi-file Editor / other IDE with sourcing directly from your sandbox modules folder. Everytime you upload, your modules get also uploaded - with prior minification - by the very Espruino IDE - and you test your most recent versions of all your sw components.

  • Thanks for the answers. So, if bundling not needed that means I need to upload the file which is the starting point of my app. Like index.js or app.js in a single page app. As I require files espruino will pack them all together and as I understand.

    I don't use the IDE. I use normal text editor and then use command line like below. Works good.

    espruino led.js -p /dev/cu.wchusbserial1420 -b 115200 --board ESP8266_4MB.json

    One thing I don't understand is what happens when I upload another file? It does not seem to overwrite the existing program. For example; I first uploaded led.js which just turns on the builtin LED.

    digitalWrite(2, 1)
    

    Then I wrote another program which is client.js and does completely something different:

    var http = require("http");
    http.get("http://www.espruino.com", function(res) {
      res.on('data', function(data) {
        console.log(data);
      });
    });
    

    What I expect; when I upload the second program, the first one will be overwritten therefore LED would turn off. But it doesn't. It seems it ignores the second program. I need to re-flash the firmware if I want to change the program inside.

About

Avatar for cuneyt @cuneyt started