I just stumbled upon this myself. Now I assume that the referenced ReferenceErrors are related to browser objects such as navigator
, window
, document
and the like. If this is the case, then this is a problem that occurs during the Dojo build process itself, because the build is done using dojo.js running inside Rhino, where global browser objects are not defined. This is a dojo / Rhino error, not a closure compiler error, so you cannot go to closure anything to change this. For example, a script like
(function(){ window.alert("hello"); })();
splits your Dojo construct if included in the Dojo layer. When the AMD Dojo loader resolves the script dependency as described above, it will run the function body, resulting in a ReferenceError link, since there is no window in Rhino.
To get around this, wrap the script as an AMD module
define([], function(){ window.alert("hello"); });
and then the function body will NOT be executed by the AMD loader during the build of Dojo.
source share