Transpiling CommonJS for in-browser use
While HTTP/2 and Packaging on the Web are still on their way, we need fast modular applications. As it was previously mentioned, we can divide the application code into CommonJS modules and transpile them for in-browser use. The most popular CommonJS transpiler is surely Browserify (http://browserify.org). The initial mission of this tool was to make Node.js modules reusable. They quite succeeded in this. It may feel like magic, but you can really use EventEmitter
and some other Node.js core modules on the client. However, with the main focus on Node.js compatibility, the tool provides too few options for CommonJS compilation. For example, if you want dependency configuration, you have to use a plugin. In a real-world project, you will likely end up with multiple plugins, where each has a specific configuration syntax. So the setup in general gets over-complicated. Rather, we'll examine here another tool called CommonJS Compiler (https://github...