You are reading a single comment by @luwar and its replies. Click here to read the full conversation.
  • What minification settings are used to make this trick work?

    There are no special minification settings required. Your module will be minified during the build of the website with the Google Closure Compiler, more precisly the Closure Compiler Service API in optimization level 'SIMPLE_OPTIMIZATIONS'.

    The minifier knows among other things that CONFIG.OS_NOTBUSY is not used and removed this variable/property. This works without additional development effort.

    If you want further minification (about 1/3 smaller) then you could use ADVANCED_MINIFACTION. You have to create an *.externs file which references your public module API. This is an easy task, but additional testing of the minified module is required!

    For the ADS1X15 it would look like:

    ADS1X15.externs:

      var ads = exports.connect( null );
      ads.setGain;
      ads.getADC;
      ads.setAddr;
      ads.getADCVoltage;
    

    The BME280 is a module which uses advance minification:
    https://github.com/espruino/EspruinoDocs­/blob/f09eaf4d68c9d772f020291341439b2560­100d20/devices/BME280.externs
    https://github.com/espruino/EspruinoDocs­/blob/f09eaf4d68c9d772f020291341439b2560­100d20/devices/BME280.js

About

Avatar for luwar @luwar started