Actually I just tried import * as name from "module-name"; and it does tree-shaking there based on the usage of the module too - so hopefully require would still allow tree-shaking (just maybe not in all cases).
I think realistically 90% of users will still use require because that's what all the existing Espruino docs use/suggest, so it'd be good if it could be made to work. Seems a shame if after all the work of adding rollup, most people never actually saw the benefits.
But yeah, this all looks really promising, With terser as well this could be a really good system.
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.
Actually I just tried
import * as name from "module-name";
and it does tree-shaking there based on the usage of the module too - so hopefullyrequire
would still allow tree-shaking (just maybe not in all cases).I think realistically 90% of users will still use
require
because that's what all the existing Espruino docs use/suggest, so it'd be good if it could be made to work. Seems a shame if after all the work of adding rollup, most people never actually saw the benefits.But yeah, this all looks really promising, With
terser
as well this could be a really good system.