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

From the page you cited, "Even better would be if Node.js supported Asynchronous Module Definitions, because those are much better suited for web browsers – no need to extract the names of required modules from the source code to preload them."

It looks like lobrow is using the 'grep Function.toSource() for require' solution. (FWIW, Function.toSource() doesn't work on a few oddball browsers, like the PS3 and Opera Mobile browsers.) If you're going to do that, requirejs is probably a more mature solution: http://requirejs.org/docs/commonjs.html#packages

I took a look at the CommonJS shims used in Narcissus -- and they're not targetted at the browser. The shim is https://github.com/mozilla/narcissus/blob/master/spidermonkey/init.js and it expects to have a synchronous 'read' method available to it, which presumably is supported by the non-browser spidermonkey shell.

I can look at rebasing the AMD changes on top of Narcissus HEAD, using the simplified wrapper in http://requirejs.org/docs/commonjs.html#manualconversion. That might let us get the benefits of AMD for the browser while keeping the Narcissus patch as small as possible.