> > > As a con-AMD folk, all I really have to point to for the > Node/CommonJS-style modules is the Node documentation/implementation. > modjewel (used by weinre) pretty much follows CommonJS standards, but > I think Node's module semantics are nicer. The path search mechanism > based on convention(node_modules, package.json, et al) I think works > out better than having to deal with CommonJS path configuration > (require.paths, or whatever). >
Paths are of minor importance - as Brian pointed out on Twitter, we're ultimately talking about one file. > The reason I'm asking for AMD specs is because I don't know what the > expectation is beyond implementing a define() function. For instance, > what are the specs for the require() function which you can request be > passed into your module factory? Likewise, what is the shape of > "module"? > > When using define(), would we be forced to pass the module id as the > first parameter, or alternatively, be forced NOT to pass the module > id, or does it work either way? If you imagine collecting AMD modules > to put in a single concatenated script for production, you obviously > need the module id's in there. Does the runtime or some tool rewrite > my modules and add the module id if I don't use one? > Is it ok to not use the pre-reqs bit? I actually prefer a literal > require() invocation in my code, and don't feel like spending my time > keeping pre-req names in an array in a function parameter, and pre-req > variables in parameters lined up. It's never been clear to me if > *not* using pre-reqs is ok. Seemed like the story was if you didn't > use pre-reqs, the module would be scanned for require() statements. > Will we support that? > For PhoneGap.js, we're dealing with a finite number of modules - around twenty I'd guess, plus one for each plugin. Typically, each module only depends on phonegap/base - it's very unlikely that, say, the Camera API would depend on the Accelerometer, although there may be cases of cross dependencies. What I would like is: * each module is its own function. I think everyone agrees with this - Gord's code compiles to this; the only difference is whether the module author writes "function ..." or a tool/compiler does * each module needs to have an id. We're ultimately going to be in a single file - putting the id right in the module definition seems like the best place. Again, Gord's code does this when it de-sugars to require.define * all dependencies specified in the `define` call, and no requires inline in the module. I would like every module-function to be passed arguments, execute its code, and return a value. No compile-time or run-time transformations, no function.toString weirdness. This seems like the most controversial point. > > -- > Patrick Mueller > http://muellerware.org >
