Hey there,
we use goog.module.ModuleManager and associated classes via ClojureScript. We kinda lagged behind a bit and were using a quite old version of the Closure Library. When updating to a newer release I ran into a couple of issues due to some changes in how the loader operates. I adapted the changes easily but I'm a bit curious how this is handled at Google or how the API is intended to be used.
a) ModuleManager.beforeLoadModuleCode(id)
This either wasn't used before or was called automatically. Why does this need to be called manually when the Loader knows exactly when it starts loading the code? The tests only call this by creating custom ModuleLoader implementations. Is the intent to subclass ModuleLoader?
b) ModuleManager.setModuleTrustedUris(obj)
I get why the TrustedResourceUrl is used but how do you get those into a build in a "trusted" fashion without resorting to hacks that use the unchecked conversion [1]? In my builds the actual URIs use unique filenames with a hash value to allow permanent caching. Since I only know the hashes after compilation I used to prepend the moduleUris via a simple "global" variable that be used as input to setModuleUris. How do I deal with URIs that aren't known at compile time (eg. dependent on some CDN info)? If everything is relying on unchecked conversions the whole "trusted" setup seems kinda pointless?
I got this working fine but it all seems rather hacky and I wonder if there is a cleaner way? Maybe there is something in the Closure Compiler that I missed which actually generates the modules to be loaded?
Regards,
Thomas
[1] goog.html.uncheckedconversions.trustedResourceUrlFromStringKnownToSatisfyTypeContract