code: function(buffer, req, res, next) {
            var moduleDir = _.find(options.moduleDirs, function(dir) {
              return req.url.indexOf(options.root + dir) === 0;
            });
  
            // Only process JavaScript that are required modules, this means
            // bailing out early if not in the module path.
            if (!moduleDir || req.url.indexOf(options.root + "vendor") > 0) {
              return next();
            }
  
            // The module name is just the JavaScript file stripped of the
            // host and location.
            var moduleName = req.url.split(moduleDir)[1];
            moduleName = moduleName.slice(1);
  
            // I'd rather work with strings here, since buffers aren't widely
            // supported.
            buffer = String(buffer);
  
            // If ES6 modules are enabled in the configuration, convert by
            // default.
            if (options.es6) {
              buffer = new Compiler(buffer, moduleName.slice(-2, 0)).toAMD();
            }
  
            // This method allows hooking into the RequireJS toolchain.
            requirejs.tools.useLib(function(require) {
              // Convert to AMD if using CommonJS, by default the conversion
              // will ignore modules that already contain a define.
              require(["commonJs"], function(commonJs) {
                var wrapped = commonJs.convert(moduleName, buffer);
                var noDefine = wrapped.indexOf("define(") === -1;
                var noConfig = wrapped.indexOf("require.config") === -1;
  
                if (noDefine && noConfig) {
                  wrapped = [
                    "define(function(require, exports, module) {",
                      wrapped,
                    "});"
                  ].join("\n");
                }
  
                res.header("Content-type", "application/javascript");
                res.end(wrapped);
              });
            });
          }
docs: Script pre-processors. "\.coffee$": require("grunt-lib-coffee").compile, "\.ts$": require("grunt-lib-typescript").compile,