From 81df8fa61e925a8fc1b97f09220b67ab25611953 Mon Sep 17 00:00:00 2001 From: jinqi6 Date: Thu, 26 Jun 2025 16:00:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B5=8C=E5=A5=97=E6=B7=B1?= =?UTF-8?q?=E5=BA=A6=E8=B6=85=E8=BF=874=20Signed-off-by:=20jinqi6=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../arkui_transformer/src/arkui_transformer.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/build-tools/arkui_transformer/src/arkui_transformer.ts b/build-tools/arkui_transformer/src/arkui_transformer.ts index 1f383ce54e..30802ad34b 100644 --- a/build-tools/arkui_transformer/src/arkui_transformer.ts +++ b/build-tools/arkui_transformer/src/arkui_transformer.ts @@ -53,6 +53,13 @@ function convertFiles(files: string[]): string[] { return result } +function getTransformationResult(sourceFile: ts.SourceFile, program: ts.Program, componentFile: ComponentFile): ts.TransformationResult { + if (uiconfig.isHdsComponent) { + return ts.transform(sourceFile, [interfaceTransformer(program, componentFile), exportAllTransformer()]); + } + return ts.transform(sourceFile, [interfaceTransformer(program, componentFile), exportAllTransformer(), addImportTransformer()]); +} + function printResult(source: string, file: ComponentFile) { const outPath = path.join(options.targetDir, file.outFileName) fs.mkdirSync(path.dirname(outPath), { recursive: true }); @@ -80,12 +87,7 @@ function main() { return (context: ts.TransformationContext) => { return (sourceFile: ts.SourceFile) => { const componentFile = componentFileMap.get(f)!; - let result; - if (uiconfig.isHdsComponent) { - result = ts.transform(sourceFile, [interfaceTransformer(program, componentFile), exportAllTransformer()]); - } else { - result = ts.transform(sourceFile, [interfaceTransformer(program, componentFile), exportAllTransformer(), addImportTransformer()]); - } + const result = getTransformationResult(sourceFile, program, componentFile); const transformedFile = ts.createSourceFile(f, printFile(result.transformed[0]), ts.ScriptTarget.Latest, true); const transformedSource = ts.createPrinter().printFile(transformedFile); printResult(transformedSource, componentFile); -- Gitee