I have been investigating how various Module concepts can be applied within Nodejs and browser applications using the the NodeJS require (obviously in NodeJS apps) and RequireJS for the web browser environment.
It then dawned on me that some modules may be useful for use by both the client and server applications and thus could be reused.
How can modules be developed so that they are compatible with both of these environments?
One is synchronous and one asynchronous. My first thought was to utilise the asynchronous syntax and then to define a custom module for NodeJS which simply invokes the asynchronous callback, synchronously. But how would the RequireJS-emulator be included into the cross-environment module without first using the NodeJS synchronous callback?
See this post : Bridging the module gap between Node.js and browsers