Taro convert转换小程序代码踩坑,持续更新中...



  • @tarojs/cli/src/convert/helper.ts的analyzeImportUrl函数只对绝对地址和相对地址的文件做处理,没有对只是模块名的做处理

    自己加了处理代码:

    let pathArr = sourceFilePath.split('/')
    let dirPath = ''
    pathArr.forEach((ele, ind) => {
        dirPath += ele + '/'
        let vpath = resolveScriptPath(path.resolve(dirPath, 'miniprogram_npm', value))
        if (vpath) {
          if (fs.existsSync(vpath)) {
            if (fs.lstatSync(vpath).isDirectory()) {
              if (fs.existsSync(path.join(vpath, 'index.js'))) {
                vpath = path.join(vpath, 'index.js')
              } else {
                printLog(processTypeEnum.ERROR, '引用目录', `文件 ${sourceFilePath} 中引用了目录 ${value}!`)
                return
              }
            }
            scriptFiles.add(vpath)
          }
        }
      })
    

    @tarojs/cli/src/convert/index.ts的parseAst函数缺少对(export * from './lib/utils/request')这种es6模块化加载的处理

    自己加了处理代码:

    ExportAllDeclaration (astPath) {
        const node = astPath.node
        const source = node.source
        const value = source.value
        analyzeImportUrl(sourceFilePath, scriptFiles, source, value)
    }
    



登录后回复