Created
May 12, 2013 16:32
-
-
Save jarek-foksa/5564115 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| window.global = window | |
| global.modules = {} | |
| imports = (moduleName) -> | |
| if not modules[moduleName] | |
| console.error "imports '#{moduleName}': module not found." | |
| return null | |
| else if modules[moduleName].exports | |
| return modules[moduleName].exports | |
| else if not modules[moduleName].closureCalled | |
| modules[moduleName].closureCalled = true | |
| modules[moduleName].closure.call undefined | |
| return modules[moduleName].exports | |
| else | |
| error = "#{moduleName}: circular module imports are not allowed. " + | |
| "Please read <docs/modules.md> for more details" | |
| console.error error | |
| return null | |
| module = (name, closure) -> | |
| modules[name] = {} | |
| modules[name].exports = null | |
| modules[name].closure = closure | |
| modules[name].closureCalled = false | |
| window.addEventListener 'load', => | |
| mainModule = document.querySelector('html').dataset.component | |
| imports(mainModule).init() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment