packages/veui-loader/src/index.js
function getParts (component, options) {
  let {
    modules = [],
    package: pack,
    path: packPath = COMPONENTS_DIRNAME,
    transform,
    fileName,
    locale,
    global = []
  } = options

  if (pack && fileName) {
    modules.push({ package: pack, path: packPath, transform, fileName })
  }

  if (locale !== false) {
    if (!locale) {
      locale = 'zh-Hans'
    }

    if (!Array.isArray(locale)) {
      locale = [locale]
    }
    locale = locale.filter(l => typeof l === 'string')
    modules = locale
      .map(l => {
        return {
          package: 'veui',
          path: `locale/${l}`,
          transform: false,
          fileName: '{module}.js'
        }
      })
      .concat(modules)

    global = locale
      .map(l => {
        return { path: `veui/locale/${l}/common.js` }
      })
      .concat(global)
  }

  return modules.reduce(
    (
      acc,
      {
        package: pack,
        path: packPath = COMPONENTS_DIRNAME,
        transform,
        fileName
      }
    ) => {
      let peerComponent = getPeerFilename(component, {
        transform,
        template: fileName
      })
      let peerPath = slash(path.join(pack, packPath, peerComponent))
      pushPart(acc, { path: peerPath })
      return acc
    },
    {
      script: [...global],
      style: []
    }
  )
}
function getParts (component, options) {
  let {
    modules = [],
    package: pack,
    path: packPath = COMPONENTS_DIRNAME,
    transform,
    fileName,
    locale,
    global = []
  } = options

  if (pack && fileName) {
    modules.push({ package: pack, path: packPath, transform, fileName })
  }

  if (locale !== false) {
    if (!locale) {
      locale = 'zh-Hans'
    }

    if (!Array.isArray(locale)) {
      locale = [locale]
    }
    locale = locale.filter(l => typeof l === 'string')
    modules = locale
      .map(l => {
        return {
          package: 'veui',
          path: `locale/${l}`,
          transform: false,
          fileName: '{module}.js'
        }
      })
      .concat(modules)

    global = locale
      .map(l => {
        return { path: `veui/locale/${l}/common.js` }
      })
      .concat(global)
  }

  return modules.reduce(
    (
      acc,
      {
        package: pack,
        path: packPath = COMPONENTS_DIRNAME,
        transform,
        fileName
      }
    ) => {
      let peerComponent = getPeerFilename(component, {
        transform,
        template: fileName
      })
      let peerPath = slash(path.join(pack, packPath, peerComponent))
      pushPart(acc, { path: peerPath })
      return acc
    },
    {
      script: [...global],
      style: []
    }
  )
}
function getParts ( component , options ) { let { modules = [ ] , package : pack , path : packPath = COMPONENTS_DIRNAME , transform , fileName , locale , global = [ ] } = options if ( pack && fileName ) { modules . push ( { package : pack , path : packPath , transform , fileName } ) } if ( locale !== false ) { if ( ! locale ) { locale = 'zh-Hans' } if ( ! Array . isArray ( locale ) ) { locale = [ locale ] } locale = locale . filter ( l => typeof l === 'string' ) modules = locale . map ( l => { return { package : 'veui' , path : ` ${ l } ` , transform : false , fileName : '{module}.js' } } ) . concat ( modules ) global = locale . map ( l => { return { path : ` ${ l } ` } } ) . concat ( global ) } return modules . reduce ( ( acc , { package : pack , path : packPath = COMPONENTS_DIRNAME , transform , fileName } ) => { let peerComponent = getPeerFilename ( component , { transform , template : fileName } ) let peerPath = slash ( path . join ( pack , packPath , peerComponent ) ) pushPart ( acc , { path : peerPath } ) return acc } , { script : [ ... global ] , style : [ ] } ) }
Extract potentially dependent parts for a component

@param {string} component Component name
@param {Object} options veui-loader options
@returns {Object} Extracted parts metadata
Extract potentially dependent parts for a component