incubator-callback-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Patrick Mueller <>
Subject Re: CommonJS and AMD (and, not or)
Date Fri, 09 Dec 2011 12:31:12 GMT
On Thu, Dec 8, 2011 at 20:55, James Burke <> wrote:

> That doc mentions how require.js can be used in dev, to get individual
> files loaded for debugging, but then have it build down to just one
> file that uses the small almond implementation of AMD.

At this point I'm fine with using AMD as our module implementation, and
something the size of almond as our deployment runtime, for folks who want
to do a "build".  I'm not sure what we do about an AMD runtime that needs
to load modules dynamically though.  Do we ship one of these with Cordova?
 Which one?  Is it replaceable?  If we ship RequireJS, can I replace it
with curl or pinf?

Also not clear regarding not-quite-standardized stuff in AMD, like configs
and plugins. Do all the AMD runtimes support these?  Where is it spec'd?

As for file conversions, for plain JS and AMD, an almond-type loader
> is fine, and for dev, requirejs can handle both of those. For CommonJS
> or node modules, the guidance could just be "make sure you convert to
> AMD before you bring it into your phonegap project, here is a utility
> to do that".

Keep in mind that at least one person in the world (me) prefers to develop
with the same runtime and semantics that I'll be using at deployment time,
meaning I'm going to develop with almond.

This implies I'm going to need to do a build.  I needed to do one anyway,
I'm using LESS, CoffeeScript, etc.  Applying AMD wrappers over CommonJS
code just adds a few more milliseconds to the build.  This is essentially
how the build for weinre works, as I noted previously in this thread.

So, there's actually a workflow which supports authoring your modules in
CommonJS.  Your guidance of "make sure you convert to AMD before you bring
it into your phonegap project" seems to imply that you can't.  Not only can
you use CommonJS modules, you can author your own CommonJS modules in your
project, if you're willing to live with the constraint of a build.  Of
course, you are free to author your module in AMD format as well.

Patrick Mueller

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message