incubator-callback-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Mueller (Commented) (JIRA)" <>
Subject [jira] [Commented] (CB-304) Cordova's require/define can't be used with Dojo's require/define
Date Thu, 08 Mar 2012 21:19:57 GMT


Patrick Mueller commented on CB-304:

The safest thing to do is to not actually expose our {{require()}}/{{define()}} as "globals"
- either properties of "window" or as "vars" off the global context.

I recently did this exact same thing to weinre, which also has {{require()}}/{{define()}},
and I anticipated problems, so fixed it in weinre.


The basic idea is that we instead just expose {{require()}}/{{define()}} as properties of
{{Cordova}} instead.  If someone wants to use our {{require()}}/{{define()}} themselves, they'll
have to opt-in by:

var require = Cordova.require
var define  = Cordova.define

We can also do this ourselves within the cordova-x.y.z.js script, by having the whole script
wrapped by a function which sets local versions as above.

We need to be a little careful to tell folks that they shouldn't use {{Cordova.require()}}
instead of {{require()}} in their modules.  Every module is passed their very own version
of {{require()}} that they *MUST USE*, as this contains contextual information about the module.
 Our version of {{require()}} doesn't do this, but eventually it will need it to handle 'relative'
requires {{require(".|../foo")}}.

The only time you'd use {{Cordova.require()}} is in the "root" modules which are loaded from
plain old JavaScript code.
> Cordova's require/define can't be used with Dojo's require/define
> -----------------------------------------------------------------
>                 Key: CB-304
>                 URL:
>             Project: Apache Callback
>          Issue Type: Bug
>          Components: CordovaJS
>            Reporter: Patrick Mueller
> summarized from
> {quote}
> I was targeting Android and used Phonegap 1.2.0 in combination with Dojo 1.7 which worked
fine. Now I switched to Phonegap 1.5.0 and found a severe problem. The new module system in
Phonegap 1.5.0 uses global functions "define" and "require". Dojo 1.7 does the same for its
own module system. Hence, whatever is loaded first, breaks the other one. 
> Could the Phonegap developers consider to modify the module system in a way that it is
compatible with Dojo's? 
> {quote}

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message