lib/babel-core/src/config/option-manager.js
function mergeOptions(config, pass) {
      var _this = this;

      var result = loadConfig(config);

      var plugins = result.plugins.map(function (descriptor) {
        return loadPluginDescriptor(descriptor);
      });
      var presets = result.presets.map(function (descriptor) {
        return loadPresetDescriptor(descriptor);
      });

      if (config.options.passPerPreset != null && typeof config.options.passPerPreset !== "boolean") {
        throw new Error(".passPerPreset must be a boolean or undefined");
      }
      var passPerPreset = config.options.passPerPreset;
      pass = pass || this.passes[0];

      // resolve presets
      if (presets.length > 0) {
        var presetPasses = null;
        if (passPerPreset) {
          var _passes;

          presetPasses = presets.map(function () {
            return [];
          });
          // The passes are created in the same order as the preset list, but are inserted before any
          // existing additional passes.
          (_passes = this.passes).splice.apply(_passes, [1, 0].concat((0, _toConsumableArray3.default)(presetPasses)));
        }

        presets.forEach(function (presetConfig, i) {
          _this.mergeOptions(presetConfig, presetPasses ? presetPasses[i] : pass);
        });
      }

      // resolve plugins
      if (plugins.length > 0) {
        var _pass;

        (_pass = pass).unshift.apply(_pass, (0, _toConsumableArray3.default)(plugins));
      }

      (0, _merge2.default)(this.options, result.options);
    }
function mergeOptions(config, pass) {
      var _this = this;

      var result = loadConfig(config);

      var plugins = result.plugins.map(function (descriptor) {
        return loadPluginDescriptor(descriptor);
      });
      var presets = result.presets.map(function (descriptor) {
        return loadPresetDescriptor(descriptor);
      });

      if (config.options.passPerPreset != null && typeof config.options.passPerPreset !== "boolean") {
        throw new Error(".passPerPreset must be a boolean or undefined");
      }
      var passPerPreset = config.options.passPerPreset;
      pass = pass || this.passes[0];

      // resolve presets
      if (presets.length > 0) {
        var presetPasses = null;
        if (passPerPreset) {
          var _passes;

          presetPasses = presets.map(function () {
            return [];
          });
          // The passes are created in the same order as the preset list, but are inserted before any
          // existing additional passes.
          (_passes = this.passes).splice.apply(_passes, [1, 0].concat((0, _toConsumableArray3.default)(presetPasses)));
        }

        presets.forEach(function (presetConfig, i) {
          _this.mergeOptions(presetConfig, presetPasses ? presetPasses[i] : pass);
        });
      }

      // resolve plugins
      if (plugins.length > 0) {
        var _pass;

        (_pass = pass).unshift.apply(_pass, (0, _toConsumableArray3.default)(plugins));
      }

      (0, _merge2.default)(this.options, result.options);
    }
function mergeOptions ( config , pass ) { var _this = this ; var result = loadConfig ( config ) ; var plugins = result . plugins . map ( function ( descriptor ) { return loadPluginDescriptor ( descriptor ) ; } ) ; var presets = result . presets . map ( function ( descriptor ) { return loadPresetDescriptor ( descriptor ) ; } ) ; if ( config . options . passPerPreset != null && typeof config . options . passPerPreset !== "boolean" ) { throw new Error ( ".passPerPreset must be a boolean or undefined" ) ; } var passPerPreset = config . options . passPerPreset ; pass = pass || this . passes [ 0 ] ; // resolve presets if ( presets . length > 0 ) { var presetPasses = null ; if ( passPerPreset ) { var _passes ; presetPasses = presets . map ( function ( ) { return [ ] ; } ) ; // The passes are created in the same order as the preset list, but are inserted before any // existing additional passes. ( _passes = this . passes ) . splice . apply ( _passes , [ 1 , 0 ] . concat ( ( 0 , _toConsumableArray3 . default ) ( presetPasses ) ) ) ; } presets . forEach ( function ( presetConfig , i ) { _this . mergeOptions ( presetConfig , presetPasses ? presetPasses [ i ] : pass ) ; } ) ; } // resolve plugins if ( plugins . length > 0 ) { var _pass ; ( _pass = pass ) . unshift . apply ( _pass , ( 0 , _toConsumableArray3 . default ) ( plugins ) ) ; } ( 0 , _merge2 . default ) ( this . options , result . options ) ; }
This is called when we want to merge the input `opts` into the
base options.

- `alias` is used to output pretty traces back to the original source.
- `loc` is used to point to the original config.
- `dirname` is used to resolve plugins relative to it.
This is called when we want to merge the input opts into the base options .