diff --git a/ets2panda/driver/build_system/src/build/base_mode.ts b/ets2panda/driver/build_system/src/build/base_mode.ts index 88ffef40cdf6d3fe2f803ffa5ffdae923c977e8d..b0e92feb752f3625141ea50f7834668e68e9df8b 100644 --- a/ets2panda/driver/build_system/src/build/base_mode.ts +++ b/ets2panda/driver/build_system/src/build/base_mode.ts @@ -526,6 +526,54 @@ export abstract class BaseMode { }); }); } + protected flushInfo(): void { + const dependentModuleMap = new Map(); + + // 建立映射 + this.dependentModuleList.forEach(moduleInfo => { + dependentModuleMap.set(moduleInfo.packageName, moduleInfo); + }); + + this.dependentModuleList.forEach(moduleInfo => { + if (!moduleInfo.dependencies) return; + + const updatedDeps: string[] = []; + + moduleInfo.dependencies.forEach(depName => { + let foundModule: DependentModuleConfig | undefined; + + foundModule = dependentModuleMap.get(depName); + if (foundModule) { + console.log(`[flushInfo] 原名命中: ${depName} (in ${moduleInfo.packageName})`); + } + + if (!foundModule) { + const withPrefix = `@alipay/${depName}`; + foundModule = dependentModuleMap.get(withPrefix); + if (foundModule) { + console.log(`[flushInfo] 加前缀命中: ${depName} → ${withPrefix} (in ${moduleInfo.packageName})`); + } + } + + if (!foundModule && depName.startsWith('@alipay/')) { + const withoutPrefix = depName.slice('@alipay/'.length); + foundModule = dependentModuleMap.get(withoutPrefix); + if (foundModule) { + console.log(`[flushInfo] 去前缀命中: ${depName} → ${withoutPrefix} (in ${moduleInfo.packageName})`); + } + } + + if (foundModule) { + updatedDeps.push(foundModule.packageName); + } else { + console.warn(`[flushInfo] 依赖未找到: ${depName} (in ${moduleInfo.packageName})`); + } + }); + + moduleInfo.dependencies = updatedDeps; + }); + } + protected collectModuleInfos(): void { if (this.hasMainModule && (!this.packageName || !this.moduleRootPath || !this.sourceRoots)) { @@ -535,6 +583,7 @@ export abstract class BaseMode { ); this.logger.printError(logData); } + this.flushInfo(); const mainModuleInfo: ModuleInfo = this.getMainModuleInfo(); this.moduleInfos.set(this.packageName, mainModuleInfo); this.dependentModuleList.forEach((module: DependentModuleConfig) => {