In order to use Espruino modules (and other CommonJS modules) a few extra steps are required, especially if you also want to uglify/minify the code. This assumes you already have Node, npm and Rollup installed.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
In order to use Espruino modules (and other CommonJS modules) a few extra steps are required, especially if you also want to uglify/minify the code. This assumes you already have Node, npm and Rollup installed.
First, install the plugins…
You need to use the "harmony" branch of the
uglify-js
library for the uglify plugin to support ES modules. This will fetch it from GitHub:Finally, add the following configuration to your Rollup config (
rollup.config.js
if using the CLI):Here I'm passing the "harmony" branch of
uglify-js
asminify
to theuglify
plugin.And with that, it should work as expected. In harmony.
Luckily, other plugins are more straight forward.