On Tue, Dec 13, 2011 at 14:56, James Burke <[email protected]> wrote:
> On Tue, Dec 13, 2011 at 11:25 AM, Brian LeRoux <[email protected]> wrote: > > Looks rad. I'm curious what an AMD plugin vs the same plugin authored > > in CJS style would look like. Just a hello world. > > Usually the only difference for coding a callback plugin in AMD or CJS > would be a define wrapper in the AMD case: > > define(function(require, exports, module){ > //CJS stuff goes in here. > }); > This is using the anonymous module pattern, instead of naming the module by passing an id as the first parameter to define(). Unfortunately, it seems difficult to convert this pattern into almond usage, as almond requires that you have an id as the first parameter (as near as I can tell, for a normal module). To use an anonymous module with almond, you have to rewrite the module to add the id at build time (ick!) or you could resort to horrible, hideous hacks (you don't want to know!). A named, wrapped CJS module as AMD would look like: define(moduleId, function(require, exports, module){ //CJS stuff goes in here. }) I'm not sure what breaks when you DO use an id; is that an issue with dynamic loading? -- Patrick Mueller http://muellerware.org
