Loading dependencies correctly across various browser targets is a surprisingly tricky affair. GCL accomplishes this by maintaining a dependency graph. When you require a namespace it will write the needed script tags in dependency order for you.
So what went wrong? If you look at
out/main.js you will see some dependency graph building calls:
goog.addDependency("base.js", ['goog'], ); goog.addDependency("../cljs/core.js", ['cljs.core'], ...); goog.addDependency("../hello_world/core.js", ['hello_world.core'], ...);
But wait, where is this
goog object coming from?
Oops. We never loaded it! In order for GCL to bootstrap we must
at least load
goog/base.js. You'll see this is available in
out/goog/base.js. Let's add this to your page now:
Refresh the page.
The error will be gone but you still won't see the desired
out/main.js didn't appear to have any of the logic that we
wrote, in fact it only includes the needed dependency graph
information for the ClojureScript standard library
cljs.core and our
Ah. The last step we missed was actually requiring our namespace to
kick things off. Change
index.html to the following.
index.html and you should finally see
thanks to source mapping (some browsers like Chrome require you to first enable source mapping, for more details look here).