lib/config/buildParser.js
function getFileFactoryOptions(build, parent, version, options, fileFactoryOptions) {
  const { fileFactory, runtimeOptions } = fileFactoryOptions;
  const hasPlugins = parent ? !!(options || version) : true;
  const needsPlugins = 'input' in build && build.input != null && !build.watchOnly;

  fileFactoryOptions.browser = build.browser;
  fileFactoryOptions.buildFactory = getBuildFactory(build);
  fileFactoryOptions.bundle = build.bundle;
  fileFactoryOptions.fileCache = build.fileCache;
  fileFactoryOptions.level = build.level + 2;
  fileFactoryOptions.pluginOptions = {};
  fileFactoryOptions.resolverCache = build.resolverCache;

  // Only load plugins for active output builds
  if (needsPlugins) {
    // Use parent's if none defined
    fileFactoryOptions.pluginOptions = hasPlugins
      ? buildPlugins.load(build.type, options, version, runtimeOptions.compress)
      : parent.fileFactoryOptions.pluginOptions;
  }

  // Overwrite fileFactory function with memoized options
  fileFactoryOptions.fileFactory = function createFile(filepath) {
    return fileFactory(filepath, fileFactoryOptions);
  };

  return fileFactoryOptions;
}
function getFileFactoryOptions(build, parent, version, options, fileFactoryOptions) {
  const { fileFactory, runtimeOptions } = fileFactoryOptions;
  const hasPlugins = parent ? !!(options || version) : true;
  const needsPlugins = 'input' in build && build.input != null && !build.watchOnly;

  fileFactoryOptions.browser = build.browser;
  fileFactoryOptions.buildFactory = getBuildFactory(build);
  fileFactoryOptions.bundle = build.bundle;
  fileFactoryOptions.fileCache = build.fileCache;
  fileFactoryOptions.level = build.level + 2;
  fileFactoryOptions.pluginOptions = {};
  fileFactoryOptions.resolverCache = build.resolverCache;

  // Only load plugins for active output builds
  if (needsPlugins) {
    // Use parent's if none defined
    fileFactoryOptions.pluginOptions = hasPlugins
      ? buildPlugins.load(build.type, options, version, runtimeOptions.compress)
      : parent.fileFactoryOptions.pluginOptions;
  }

  // Overwrite fileFactory function with memoized options
  fileFactoryOptions.fileFactory = function createFile(filepath) {
    return fileFactory(filepath, fileFactoryOptions);
  };

  return fileFactoryOptions;
}
function getFileFactoryOptions ( build , parent , version , options , fileFactoryOptions ) { const { fileFactory , runtimeOptions } = fileFactoryOptions ; const hasPlugins = parent ? ! ! ( options || version ) : true ; const needsPlugins = 'input' in build && build . input != null && ! build . watchOnly ; fileFactoryOptions . browser = build . browser ; fileFactoryOptions . buildFactory = getBuildFactory ( build ) ; fileFactoryOptions . bundle = build . bundle ; fileFactoryOptions . fileCache = build . fileCache ; fileFactoryOptions . level = build . level + 2 ; fileFactoryOptions . pluginOptions = { } ; fileFactoryOptions . resolverCache = build . resolverCache ; // Only load plugins for active output builds if ( needsPlugins ) { // Use parent's if none defined fileFactoryOptions . pluginOptions = hasPlugins ? buildPlugins . load ( build . type , options , version , runtimeOptions . compress ) : parent . fileFactoryOptions . pluginOptions ; } // Overwrite fileFactory function with memoized options fileFactoryOptions . fileFactory = function createFile ( filepath ) { return fileFactory ( filepath , fileFactoryOptions ) ; } ; return fileFactoryOptions ; }
Retrieve file factory options for 'build'
@param {Build} build
@param {Build} [parent]
@param {Object} version
@param {Object} options
@param {Object} fileFactoryOptions
@returns {Function}
Retrieve file factory options for build