int3/jsshaper — comment on commit c18505c090d582671f715621290f2f0d19a65fe2
File:  line 0
By cscott:

The big disadvantage is that there isn't much support for CommonJS modules in the browser -- as far as I know, the tools you expect to exist, don't. AMD has limited support for converting CommonJS modules to AMD modules, but using Function.toSource() and grepping for the requires -- but ugh. It's a shame to add one level of nesting, but it's not really the end of the world.

AMD fits pretty well with the node community; there's a 'requirejs' module for node that fits in really well, is available from npm etc. I chose to use the lighter-weight 'amdefine' module in order to minimize shaper's external dependencies. They interoperate; if you're already using requirejs, then it's define cleanly replaces the amdefine thunk.

On the other hand, it looks like Narcissus upstream has adopted a CommonJS module structure. I need to look at that more closely to see how evil that is. At the moment, I've rebased up to the point where they switched to CommonJS (and renamed all the files while they were at it, ugh.) Anyway, we can take it in pieces. I'll give you the first part of the rebase (not including AMD-ification) in a few minutes.