Nearsighted Paramecium Multiverse


    0.2.1 • Public • Published


    Rollup plugin for sending bundled code to an Espruino device.

    Rollup produces very lean code from modules, with treeshaking and no overhead if using es as the output format. Perfect for Espruino.

    With this plugin, bundled code will be sent to one or more Espruino devices after the dest file has been written to disk. That means it requires the use of bundle.write() if running Rollup from JavaScript, or dest if using a configuration file. Having the file also written to disk is a good thing, as you can see exactly what was sent to Espruino.

    Any uncaught errors in the code sent to Espruino will be shown in the terminal, to help with debugging.

    The plugin exits the process when done, so it must be the last plugin. It should be compatible with most other Rollup plugins, here are some that may be useful in an Espruino project:

    More plugins here


    Using NPM:

    npm install rollup-plugin-espruino --save

    Using Yarn:

    yarn add rollup-plugin-espruino

    Sending to Espruino devices (like Puck.js) over Bluetooth LE also requires the noble package.


    Example configuration file (rollup.config.js):

    import espruino from 'rollup-plugin-espruino'
    export default {
      entry: 'src/main.js',
      dest: 'dist/bundle.js',
      format: 'es',
      plugins: [
          port: 'aa:bb:cc:dd:ee', // or ['/dev/ttyX', 'aa:bb:cc:dd:ee']
          setTime: true,
          save: true,

    Make sure the espruino plugin is the last.

    The above configuration file would run by executing the command rollup -c from the same directory.

    It is also possible to use Rollup's JavaScript API. If you do, you'll have to write the bundle to disk using bundle.write() for this plugin to run.


    All options are optional.


    Specify port(s) or device address(es) to connect to. May either be a string or an array of strings.

    Defaults to searching for ports and picking the first found.


    Reset the Espruino device before sending code.

    Boolean, defaults to true.


    Save the code on the Espruino device after sending.

    Boolean, defaults to false.


    Set Espruino's clock to the current time when sending code.

    Boolean, defaults to false.


    Connect to Espruino devices over Bluetooth LE (requires the noble package to be installed alongside this plugin).

    Boolean, defaults to true.


    Connect to Espruino devices over the headphone jack.

    Possible values:

    • 0 - Disabled
    • PP - Normal Signal Polarity
    • NN - Fully Inverted
    • NP - Input Inverted
    • PN - Output Inverted

    Defaults to 0 (disabled).


    The baud rate that is used when connecting to Espruino devices over serial.

    Number, defaults to 9600, which is the default for Espruino.


    Throttle code when sending to Espruino. If you are experiencing lost characters when sending code, this may help.

    Boolean, defaults to false.


    Show output from Espruino while sending code.

    Boolean, defaults to false.


    Show verbose output from the underlying espruino package. Not pretty, but sometimes useful.

    Boolean, defaults to false.



    Using rollup-plugin-uglify with ES modules is a little tricky, but this forum post shows you how.

    To achieve maximum minification, enable the toplevel mangle option like so:

      plugins: [
          mangle: {
            toplevel: true,
        }, minify),

    Espruino modules

    To use Espruino's modules, you have to first download them to your project's directory and import them as local files.

    Hopefully this can be made as easy as in Espruino's Web IDE some day, where modules are automatically downloaded when require()d in code.


    MIT © Joakim Stai


    npm i rollup-plugin-espruino

    DownloadsWeekly Downloads






    Last publish


    • joakimstai