2***@qq.com
2***@qq.com
  • 发布:2023-09-14 12:08
  • 更新:2023-10-17 14:14
  • 阅读:230

编译小程序报Cannot read properties of null (reading 'getVariableForExportName')

分类:uni-app

之前一直好好的,今天运行编译微信小程序就报这个错误了。搜索无果。getVariableForExportName这个方法也找不到。

2023-09-14 12:08 负责人:无 分享
已邀请:
小何同学

小何同学 - https://github.com/xiaohe0601

是Rollup在Tree Shake的时候报错了,具体是uni-app的bug还是Rollup的还没去研究,可以在node-entry中添加一个判断临时解决

node_modules/rollup/dist/es/shared/node-entry.js

traceVariable(name, { importerForSideEffects, isExportAllSearch, searchedNamesAndModules } = EMPTY_OBJECT)  
{  
  const localVariable = this.scope.variables.get(name);  
  if (localVariable) {  
    return localVariable;  
  }  
  const importDescription = this.importDescriptions.get(name);  
  if (importDescription) {  
    const otherModule = importDescription.module;  
    if (otherModule instanceof Module && importDescription.name === '*') {  
      return otherModule.namespace;  
    }  
    // 添加这个判断  
    if (otherModule == null) {  
      return null;  
    }  
    const [declaration] = getVariableForExportNameRecursive(otherModule, importDescription.name, importerForSideEffects || this, isExportAllSearch, searchedNamesAndModules);  
    if (!declaration) {  
      return this.error(logMissingExport(importDescription.name, this.id, otherModule.id), importDescription.start);  
    }  
    return declaration;  
  }  
  return null;  
}

要回复问题请先登录注册