IDE: Module not found ... built in modules?

Posted on
  • I find that when I write a JavaScript which includes a "built in" module ... I get an IDE popup warning saying that the module was not found. For example:

    var http = require("http");
    

    Could this be because the IDE is looking to find the module from an external repository but the module is actually not going to be found since it is built in?

    Neil

  • Ahh - that's actually a side-effect of you using ESP8266, which doesn't have any info listed on the Espruino site.

    When you first connect, the IDE asks the board what it is, and then it looks online for more info. For instance for the Pico it gets this file, which tells it which modules are built in as well as all kinds of extra info about pins and stuff.

    It's auto-generated from the BOARD.py file, so when you submit the ESP8266 port it'll go on the website.

    In the longer term it's probably more sensible to have the board itself report that back (as you can have different builds with different stuff built in), but that could be added later. There's also the risk of the board having to send too much information back when you connect (for instance you don't want it to send all the info about its pins, as that would really add a noticeable delay to the connection).

  • I assume 'this file' is used to supply the IDE with data for auto completion and other useful 'stuff' - also at runtime.

    Could this file be stored online and identified by a build (scope) ID? Or could be be transmitted ansd stored in the context of the IDE if not found (yet)? And in order to completely offload the device from having this file stored or having to store (wasting memory) and having it to transmit (everytime on connect wasting time), this file could be pulled from a store like the modules are for for upload to the board. A build builder's responsibility includes then to make this file available just as the built file... like source maps for (closure) compiled code. The only challenge is then to crate a unique id for the build... may be a sh1 or-a-like (like used in git) could do the job... still a fraction of bytes compered to all the bytes in 'this file'.

    Having this file not anymore available at runtime... that would need a rethinking and separation of information for the IDE support and information for the runtime support.

  • I assume 'this file' is used to supply the IDE with data for auto completion and other useful 'stuff' - also at runtime.

    Yep.

    I guess a nice solution would be to include a full URL in the board, then the Web IDE could check there. However for the moment the current solution works fine - I just have to have put the JSON file up.

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

IDE: Module not found ... built in modules?

Posted by Avatar for Kolban @Kolban

Actions