[OpenLayers-Dev] @require issue with XHR code

Eric Lemoine eric.c2c at gmail.com
Tue Jun 10 11:58:09 EDT 2008


I'd rather go with @includebefore (replacing requires) and @include.

2008/6/10, Tim Schaub <tschaub at opengeo.org>:
> Hey-
>
> Christopher Schmidt wrote:
>> 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,
>
> Yeah, I was going to suggest
>
> @requires - Target script must be included before this one.
> @include - Target script must be included somewhere in the build.
>
> For now, requires XMLHttpRequest.js is a good solution.  (There are
> other places where we don't have @requires because of this circular
> conflict - Format.WKT should include the Geometry subclasses, but it
> doesn't because those require Geometry and Geometry requires Format.WKT.)
>
> Tim
>
>
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
>



More information about the Dev mailing list