[OpenLayers-Dev] @require issue with XHR code

Christopher Schmidt crschmidt at metacarta.com
Tue Jun 10 10:39:32 EDT 2008


On Tue, Jun 10, 2008 at 04:11:36PM +0200, Eric Lemoine wrote:
> Hi
> 
> There's a dependency issue with the new XHR code.
> 
> If you have A.js that uses say Request.GET, in A.js you will use:
> 
> /*
>  * @requires OpenLayers/Request.js
>  */
> 
> The thing is that Request.js doesn't include "@require
> OpenLayers/Request/XMLHttpRequest.js", so the built file won't include
> the XMLHttpRequest code, which is problematic.
> 
> Adding "@require OpenLayers/Request/XMLHttpRequest.js" to Request.js
> comes up with its own problem: a circular reference. Yes,
> XMLHttpRequest.js does include "@require OpenLayers/Request.js". And
> if we remove that @require in XMLHttpRequest.js, it doesn't work
> either, because XMLHttpRequest.js does require Request.js when its
> main anonymous function is executed.
> 
> One solution to this entire issue might be use
> 
> /*
>  * @requires OpenLayers/Request/XMLHttpRequest.js
>  */
> 
> everywhere the Request object is used. But it's a bit confusing.
> 
> Any other idea?

Another solution is to update the build tools to do something smarter
with circular dependancies. This really all comes down to the fact that
there is no seperation between "requires-at-build-time" vs. "requires at
run-time" -- dependancies were (originally) about build time, but as the
build system and requirements have gotten more complicated, there has
been a need to make that more about run time instead.

Seperating out the two is a project that probably needs doing.

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Dev mailing list