packages/cli-config/src/load.js
function loadPlugin(descriptor, loader) {
  const config = Array.isArray(descriptor) ? descriptor : [descriptor];
  const [name, options = {}] = config;
  const { error, module: plugin } = loader(name);

  if (error) {
    return {
      error,
      name,
    };
  }

  if (typeof plugin !== 'function') {
    return {
      error: new Error(
        `Expected the plugin \`${name}\` to export a function, instead ` +
          `recieved: ${typeof plugin}`
      ),
      name,
    };
  }

  return {
    name,
    options,
    plugin,
  };
}
function loadPlugin(descriptor, loader) {
  const config = Array.isArray(descriptor) ? descriptor : [descriptor];
  const [name, options = {}] = config;
  const { error, module: plugin } = loader(name);

  if (error) {
    return {
      error,
      name,
    };
  }

  if (typeof plugin !== 'function') {
    return {
      error: new Error(
        `Expected the plugin \`${name}\` to export a function, instead ` +
          `recieved: ${typeof plugin}`
      ),
      name,
    };
  }

  return {
    name,
    options,
    plugin,
  };
}
function loadPlugin ( descriptor , loader ) { const config = Array . isArray ( descriptor ) ? descriptor : [ descriptor ] ; const [ name , options = { } ] = config ; const { error , module : plugin } = loader ( name ) ; if ( error ) { return { error , name , } ; } if ( typeof plugin !== 'function' ) { return { error : new Error ( ` \` ${ name } \` ` + ` ${ typeof plugin } ` ) , name , } ; } return { name , options , plugin , } ; }
Load the plugin descriptor with the given loader
@param {Descriptor} descriptor
@param {Loader} loader
Load the plugin descriptor with the given loader