Skip to content

Instantly share code, notes, and snippets.

@bitmage
Created January 7, 2012 02:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitmage/1573477 to your computer and use it in GitHub Desktop.
Save bitmage/1573477 to your computer and use it in GitHub Desktop.
Compilation for RZR load macro
================================================================
# Key
<- indicates a dependency
-> indicates a result
================================================================
# pre-build (all settings default to user dotfile, then factory settings)
<- find project root
<- require project config
<- require macro definitions file
# loading a module
load 'foo.fooService'
<- macro definition
-> require([resolve getModulePath 'project-root', 'foo.fooService']);
# general resolve-at-compile-time macro
resolve getModulePath 'project-root', 'foo.fooService'
-> eval compile["getModulePath 'project-root', 'foo.fooService'"]
# return string of eval
eval "getModulePath('project-root', 'foo.fooService');"
-> '../../domain/foo/services/fooService.js'
# result of load 'foo.fooService'
-> require('../../domain/foo/services/fooService.js');
# NOTES:
# 1. If we create a function with the same signature as the macro that resolves the load path at run time, we can gracefully depricate if someone disables the macro. Perhaps there's a general way to do this for all the defined macros.
# 2. Finding/loading macro definitions in prebuild means they'll be available for compile time eval() context. Conversely, anything *not* loaded into the macro definitions will *not* be available. getModulePath would have to be defined or referenced from the macro file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment