in many cases that would be great if we could use defines like in c# and other things like #if, #elif, #define. Because of this we could make that we could have different code for live and preview stages, this would also work in other cases. What do you think about this?
You can check what stage you are current on in Cloud Code with "var stage = Spark.getConfig().getStage();" This will return either "live" or "preview", so you would be able to have specific code or modules set up to run after you have checked what stage you are on. Does that sound like it would work for you here ?
these constant structures could be stored in a module and used where needed through out the cloud code base. Hope this helps.
What I've done in the past is added any directives I wish to use as variables at the top of my code:
var DEBUG = false; var PROFILING = false;
Then later in my code I use plain old if statements to check for those variables. This has served me well enough in the past.