On Mon, Oct 22, 2012 at 10:04 AM, Gord Tanner <g...@tinyhippos.com> wrote:
> My main idea with sweet.js would be to replace a couple of the build time transforms we already do in cordova.js: > > module.exports = { > }; > > to > > define("filename", function (require, define, module) { > module.exports = { > }; > }; > So convert a node.js styled module, into an AMD-styled one, using macros, instead of the bit-o'code that we already have. Not sure there's enough bang for the buck there. > as well as the version number updating. > Ya, maybe. So we have some macro that looks like a function invocation, which maybe at dev time reads a file, but we "compile" at build time into a string literal. My previous experience with such things is that you need to make the name of the macro (in this case) very obvious that it's something replaced at compile/build-time, otherwise it's difficult to tell what's going on if you just look at the code. The easiest way to play with this is to have the pre-compiled source code also be valid JS code, so it will basically work when you run the pre-compiled version. It is just a thought but would be nice to use macros to handle those > transforms and maybe start adding some ES Harmony style macro's to > cordova.js (Just for our code, not leaking into user code yet). > > for example: > > var foo = {func: (a) => { return a + 1; }}; > This violates the "allow the pre-compiled version to still run as JS", so I'd say "yeah, maybe in the future, once we're happy with infesting our code with macros". -- Patrick Mueller http://muellerware.org