I am switching out browser-require for require.js in a branch today to see what this would feel like for a developer.
I have no preference as to which module system we use so I am going to give this a go today to learn AMD modules / requireJS and get a feel for how it would look in phonegap.js development. Gord On Fri, Dec 9, 2011 at 7:31 AM, Patrick Mueller <[email protected]> wrote: > On Thu, Dec 8, 2011 at 20:55, James Burke <[email protected]> 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 > http://muellerware.org > -- Gord Tanner Senior Developer / Code Poet tinyHippos Inc. @tinyhippos
