yahoo/mojito — pull request #1375 by aljimenez (2014-05-28 00:02:44+00:00)
Title: Read YUI modules only once

Currently YUI modules are read twice; once to capture YUI metadata and then again when they are actually added to the runtime YUI. This is inefficient since each module requires two synchronous reads, and potentially problematic since part of the code is executed twice. This pull request manages to capture YUI metadata and adds YUI modules at the same time by hooking into the YUI.add method. This reduces startup time by up to 20%, and only executes modules once with the actual YUI object. Instead of using VM to execute modules, it does exactly what YUI does (wrapping code in module.exports); this actually allows us to capture the line number of syntax errors and runtime errors within the module (VM does not give line numbers).