originjs/vite-plugin-federation

Can not read rollup.external when it's type is RegExp

AttackXiaoJinJin opened this issue · 0 comments

Versions

  • vite-plugin-federation: ^1.3.3
  • vite: ^4.5.0

Reproduction

remote vite.config.js:

build:{
    rollupOptions:{
      external: [/^aaa/]
    }
  },

run build and:

image

THE CODE IS:

inputOptions.external = (inputOptions.external as [])?.filter(

get external and use removeNonRegLetter

 inputOptions.external = (inputOptions.external as [])?.filter(
          (item) => {
            return !shareName2Prop.has(removeNonRegLetter(item, NAME_CHAR_REG))
          }
        )

export function removeNonRegLetter(str: string, reg = letterReg): string {

export function removeNonRegLetter(str: string, reg = letterReg): string {
  let needUpperCase = false
  let ret = ''
  for (const c of str) {
    if (reg.test(c)) {
      ret += needUpperCase ? c.toUpperCase() : c
      needUpperCase = false
    } else {
      needUpperCase = true
    }
  }
  return ret
}

removeNonRegLetter first param SHOULD BE string|RegExp

https://rollupjs.org/configuration-options/#external

image