src/node/recursiveModuleCompile.js
function recursiveModuleCompile(fileNamesAndTypes, options) {
  var referrerName = options && options.referrer;

  var basePath = path.resolve('./') + '/';
  basePath = basePath.replace(/\\/g, '/');

  var elements = [];
  var loaderCompiler = new InlineLoaderCompiler(elements);

  var loader = new TraceurLoader(nodeLoader, basePath, loaderCompiler);

  function appendEvaluateModule(name) {
    var normalizedName =
        $traceurRuntime.ModuleStore.normalize(name, referrerName);
    // Create tree for $traceurRuntime.getModule('normalizedName');
    var moduleModule = traceur.codegeneration.module;
    var tree = moduleModule.createModuleEvaluationStatement(normalizedName);
    elements.push(tree);
  }

  function loadInput(input) {
    var doEvaluateModule = false;
    var loadFunction = loader.import;
    var name = input.name;

    var optionsCopy = new Options(options); // Give each load a copy of options.

    if (input.type === 'script') {
      loadFunction = loader.loadAsScript;
    } else if (optionsCopy.modules === 'bootstrap') {
      doEvaluateModule = true;
    }

    var loadOptions = {
      referrerName: referrerName,
      metadata: {
        traceurOptions: optionsCopy,
        rootModule: input.rootModule && input.name
      }
    };

    return loadFunction.call(loader, name, loadOptions).then(function() {
      if (doEvaluateModule) {
        appendEvaluateModule(name);
      }
    });
  }

  return sequencePromises(fileNamesAndTypes, loadInput).then(function() {
    return loaderCompiler.toTree();
  });
}
function recursiveModuleCompile(fileNamesAndTypes, options) {
  var referrerName = options && options.referrer;

  var basePath = path.resolve('./') + '/';
  basePath = basePath.replace(/\\/g, '/');

  var elements = [];
  var loaderCompiler = new InlineLoaderCompiler(elements);

  var loader = new TraceurLoader(nodeLoader, basePath, loaderCompiler);

  function appendEvaluateModule(name) {
    var normalizedName =
        $traceurRuntime.ModuleStore.normalize(name, referrerName);
    // Create tree for $traceurRuntime.getModule('normalizedName');
    var moduleModule = traceur.codegeneration.module;
    var tree = moduleModule.createModuleEvaluationStatement(normalizedName);
    elements.push(tree);
  }

  function loadInput(input) {
    var doEvaluateModule = false;
    var loadFunction = loader.import;
    var name = input.name;

    var optionsCopy = new Options(options); // Give each load a copy of options.

    if (input.type === 'script') {
      loadFunction = loader.loadAsScript;
    } else if (optionsCopy.modules === 'bootstrap') {
      doEvaluateModule = true;
    }

    var loadOptions = {
      referrerName: referrerName,
      metadata: {
        traceurOptions: optionsCopy,
        rootModule: input.rootModule && input.name
      }
    };

    return loadFunction.call(loader, name, loadOptions).then(function() {
      if (doEvaluateModule) {
        appendEvaluateModule(name);
      }
    });
  }

  return sequencePromises(fileNamesAndTypes, loadInput).then(function() {
    return loaderCompiler.toTree();
  });
}
function recursiveModuleCompile ( fileNamesAndTypes , options ) { var referrerName = options && options . referrer ; var basePath = path . resolve ( './' ) + '/' ; basePath = basePath . replace ( / \\ / g , '/' ) ; var elements = [ ] ; var loaderCompiler = new InlineLoaderCompiler ( elements ) ; var loader = new TraceurLoader ( nodeLoader , basePath , loaderCompiler ) ; function appendEvaluateModule ( name ) { var normalizedName = $traceurRuntime . ModuleStore . normalize ( name , referrerName ) ; // Create tree for $traceurRuntime.getModule('normalizedName'); var moduleModule = traceur . codegeneration . module ; var tree = moduleModule . createModuleEvaluationStatement ( normalizedName ) ; elements . push ( tree ) ; } function loadInput ( input ) { var doEvaluateModule = false ; var loadFunction = loader . import ; var name = input . name ; var optionsCopy = new Options ( options ) ; // Give each load a copy of options. if ( input . type === 'script' ) { loadFunction = loader . loadAsScript ; } else if ( optionsCopy . modules === 'bootstrap' ) { doEvaluateModule = true ; } var loadOptions = { referrerName : referrerName , metadata : { traceurOptions : optionsCopy , rootModule : input . rootModule && input . name } } ; return loadFunction . call ( loader , name , loadOptions ) . then ( function ( ) { if ( doEvaluateModule ) { appendEvaluateModule ( name ) ; } } ) ; } return sequencePromises ( fileNamesAndTypes , loadInput ) . then ( function ( ) { return loaderCompiler . toTree ( ) ; } ) ; }
Compiles the files in "fileNamesAndTypes" along with any associated modules,
into a single js file, in module dependency order.

@param {Array<Object>} fileNamesAndTypes The list of {name, type}
to compile and concat; type is 'module' or 'script'
@param {Object} options A container for misc options. 'referrer' is the
only currently available option.
@param {Function} callback Callback used to return the result. A null result
indicates that recursiveModuleCompile has returned successfully from a
non-compile request.
@param {Function} errback Callback used to return errors.
Compiles the files in fileNamesAndTypes along with any associated modules into a single js file in module dependency order .