From 015b6e69d6e2a3a09f4311ef882c2310824447a1 Mon Sep 17 00:00:00 2001 From: lihao Date: Fri, 20 Jun 2025 11:43:33 +0800 Subject: [PATCH] bugfix:Is arkts evolution file Issue: https://gitee.com/openharmony/developtools_ace_ets2bundle/issues/ICGKJA Signed-off-by: lihao --- compiler/src/process_arkts_evolution.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/compiler/src/process_arkts_evolution.ts b/compiler/src/process_arkts_evolution.ts index 7c0fb0a64..6c6cdc8da 100644 --- a/compiler/src/process_arkts_evolution.ts +++ b/compiler/src/process_arkts_evolution.ts @@ -18,6 +18,7 @@ import path from 'path'; import ts from 'typescript'; import { + EXTNAME_TS, EXTNAME_ETS, EXTNAME_D_ETS, ARKTS_1_0, @@ -136,6 +137,19 @@ export function getArkTSEvoDeclFilePath(resolvedFileInfo: ResolvedFileInfo): str pkgName, toUnixPath(path.join(declgenV1OutPath, pkgName, 'src/main/ets')) ) + EXTNAME_D_ETS; + + if (fs.existsSync(arktsEvoDeclFilePath)) { + break; + } + /** + * If the import is exported via the package name, for example: + * import { xxx } from 'src/main/ets/xxx/xxx/...' + * there is no need to additionally concatenate 'src/main/ets' + */ + arktsEvoDeclFilePath = moduleRequest.replace( + pkgName, + toUnixPath(path.join(declgenV1OutPath, pkgName)) + ) + EXTNAME_D_ETS; break; } } @@ -252,7 +266,12 @@ export function isArkTSEvolutionFile(filePath: string, metaInfo: Object): boolea const normalizedFilePath = toUnixPath(filePath); const staticFileList = hybridModule.staticFiles || []; - return new Set(staticFileList.map(toUnixPath)).has(normalizedFilePath); + // Concatenate the corresponding source code path based on the bridge code path. + const declgenCodeBrigdePath = path.join(toUnixPath(hybridModule.declgenBridgeCodePath), metaInfo.pkgName); + let moduleId = normalizedFilePath.replace(toUnixPath(declgenCodeBrigdePath), toUnixPath(metaInfo.pkgPath)); + const arktsEvolutionFile = moduleId.replace(new RegExp(`\\${EXTNAME_TS}$`), EXTNAME_ETS); + + return new Set(staticFileList.map(toUnixPath)).has(arktsEvolutionFile); } return false; -- Gitee