You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by "Patrick Mueller (Commented) (JIRA)" <ji...@apache.org> on 2012/03/08 22:19:57 UTC

[jira] [Commented] (CB-304) Cordova's require/define can't be used with Dojo's require/define

    [ https://issues.apache.org/jira/browse/CB-304?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13225530#comment-13225530 ] 

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.

see: https://issues.apache.org/jira/browse/CB-293

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:

{noformat}
var require = Cordova.require
var define  = Cordova.define
{noformat}

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: https://issues.apache.org/jira/browse/CB-304
>             Project: Apache Callback
>          Issue Type: Bug
>          Components: CordovaJS
>            Reporter: Patrick Mueller
>
> summarized from https://groups.google.com/d/topic/phonegap/D1cm3kQzKJ0/discussion
> {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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira