-
• #2
That's great - thanks! As long as it's tested then yes, a PR would be really good.
-
• #3
[edited] PR completed. In the end rather than strip down all the variable names, I made the new version compatible with Closure advanced optimisation and contributed a .min.js made via that route.
-
• #4
made the new version compatible with Closure advanced optimisation and contributed a .min.js made via that route.
...will come to your knowledge-sharing brown-bag session/class about that. When and where will take place?
-
• #5
Thanks! It's interesting to see the changes needed to allow advanced optimisations. I might actually get rid of the
.min.js
file itself, because I imagine it could cause trouble in the long run (PRs from someone that changes one file but not the other), but I'll modifyminify.js
to search for some special token in the unminified file (likeADVANCED_MINIFY
) and to then turn on advanced optimisations. That should allow us to turn it on for some other files too. -
• #6
@allObjects it's pretty straightforward. The basic rule is refer to anything you don't want minified as an indirect property reference, so me.property should be written as me['property']. After minification is applied, this goes back to me.property, so although the unoptimised code looks more prolix, the minified is fine. The main problem seems to me that someone later will "improve" the unminified code so that it stops working with advanced optimisation. I looked at using the exports and externs options in advanced optimisation https://developers.google.com/closure/compiler/docs/api-tutorial3?hl=en but they don't work well for the Espruino use case as is. Externs could work with some changes to WebIDE perhaps.
-
• #7
Just an aside on externs in Closure. In advanced compilation, it would be helpful to have an Espruino externs file which would prevent minification for example to methods of E or other Espruino bundled classes. I might have a go at this at some point. With more work, every module intended for Closure advanced optimisation could have an extern file to prevent references to it being minified when used with Closure. I am unlikely to find time for this.
The BME280 module is a bit unnecessarily large, so I'm refactoring it, primarily to remove unnecessary variable declarations and debugging code, reduce the length of non-minifiable public method names and generally tidy up a bit.
Is there a protocol for this sort of thing, eg discussing here, or should I just change and create a pull request?
FWIW here's the code, anything else?