From 60db3bc00870b34df2248c21a54403eb571251ee Mon Sep 17 00:00:00 2001 From: x30053363 Date: Tue, 9 Sep 2025 22:27:43 +0800 Subject: [PATCH] UseTsHar support incBuild Issue: https://gitee.com/openharmony/developtools_ace_ets2bundle/issues/ICX73O Signed-off-by: x30053363 Change-Id: I1684ec4dea11c5e8b0d59aa778c9e7203246ac54 --- compiler/src/ets_checker.ts | 14 +++++++++----- compiler/src/interop/src/ets_checker.ts | 14 +++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index 8ad8a7c17..495b9c69a 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -112,6 +112,7 @@ export interface LanguageServiceCache { targetESVersion?: ts.ScriptTarget; types?: string[]; maxFlowDepth?: number; + useTsHar?: boolean; preTsImportSendable?: boolean; preSkipOhModulesLint?: boolean; preEnableStrictCheckOHModule?: boolean; @@ -460,19 +461,21 @@ function getOrCreateLanguageService(servicesHost: ts.LanguageServiceHost, rootFi const targetESVersionDiffers: boolean | undefined = lastTargetESVersion && currentTargetESVersion && lastTargetESVersion !== currentTargetESVersion; const typesDiff: boolean | undefined = lastTypes && currentTypes && !areEqualArrays(lastTypes, currentTypes); const maxFlowDepthDiffers: boolean | undefined = lastMaxFlowDepth && currentMaxFlowDepth && lastMaxFlowDepth !== currentMaxFlowDepth; + const useTsHarDiff: boolean = checkValueDiff(cache?.useTsHar, projectConfig.useTsHar); const tsImportSendableDiff: boolean = checkValueDiff(cache?.preTsImportSendable, tsImportSendable); const skipOhModulesLintDiff: boolean = checkValueDiff(cache?.preSkipOhModulesLint, skipOhModulesLint); const enableStrictCheckOHModuleDiff: boolean = checkValueDiff(cache?.preEnableStrictCheckOHModule, enableStrictCheckOHModule); const mixCompileDiff: boolean = checkValueDiff(cache?.preMixCompile, mixCompile); const onlyDeleteBuildInfoCache: boolean | undefined = tsImportSendableDiff || maxFlowDepthDiffers || skipOhModulesLintDiff || enableStrictCheckOHModuleDiff || mixCompileDiff || typesDiff; - const shouldRebuild: boolean | undefined = shouldRebuildForDepDiffers || targetESVersionDiffers || onlyDeleteBuildInfoCache; + const shouldInvalidCache: boolean | undefined = targetESVersionDiffers || useTsHarDiff; + const shouldRebuild: boolean | undefined = shouldRebuildForDepDiffers || shouldInvalidCache || onlyDeleteBuildInfoCache; if (reuseLanguageServiceForDepChange && hashDiffers && rollupShareObject?.depInfo?.enableIncre) { needReCheckForChangedDepUsers = true; } if (!service || shouldRebuild) { - rebuildProgram(targetESVersionDiffers, onlyDeleteBuildInfoCache); + rebuildProgram(shouldInvalidCache, onlyDeleteBuildInfoCache); service = ts.createLanguageService(servicesHost, ts.createDocumentRegistry()); } else { // Found language service from cache, update root files @@ -486,6 +489,7 @@ function getOrCreateLanguageService(servicesHost: ts.LanguageServiceHost, rootFi targetESVersion: currentTargetESVersion, types: currentTypes, maxFlowDepth: currentMaxFlowDepth, + useTsHar: projectConfig.useTsHar, preTsImportSendable: tsImportSendable, preSkipOhModulesLint: skipOhModulesLint, preMixCompile: mixCompile @@ -524,9 +528,9 @@ export function areEqualArrays(lastArray: string[] | undefined, currentArray: st return true; } -function rebuildProgram(targetESVersionDiffers: boolean | undefined, onlyDeleteBuildInfoCache: boolean | undefined): void { - if (targetESVersionDiffers) { - // If the targetESVersion is changed, we need to delete the build info cahce files +function rebuildProgram(shouldInvalidCache: boolean | undefined, onlyDeleteBuildInfoCache: boolean | undefined): void { + if (shouldInvalidCache) { + // If the targetESVersion or usTsHar is changed, we need to delete the build info cahce files & rollup caches deleteBuildInfoCache(compilerOptions.tsBuildInfoFile); targetESVersionChanged = true; } else if (onlyDeleteBuildInfoCache) { diff --git a/compiler/src/interop/src/ets_checker.ts b/compiler/src/interop/src/ets_checker.ts index 543618eb9..71220f7da 100644 --- a/compiler/src/interop/src/ets_checker.ts +++ b/compiler/src/interop/src/ets_checker.ts @@ -125,6 +125,7 @@ export interface LanguageServiceCache { targetESVersion?: ts.ScriptTarget; types?: string[]; maxFlowDepth?: number; + useTsHar?: boolean; preTsImportSendable?: boolean; preSkipOhModulesLint?: boolean; preEnableStrictCheckOHModule?: boolean; @@ -480,19 +481,21 @@ function getOrCreateLanguageService(servicesHost: ts.LanguageServiceHost, rootFi const targetESVersionDiffers: boolean | undefined = lastTargetESVersion && currentTargetESVersion && lastTargetESVersion !== currentTargetESVersion; const typesDiff: boolean | undefined = lastTypes && currentTypes && !areEqualArrays(lastTypes, currentTypes); const maxFlowDepthDiffers: boolean | undefined = lastMaxFlowDepth && currentMaxFlowDepth && lastMaxFlowDepth !== currentMaxFlowDepth; + const useTsHarDiff: boolean = checkValueDiff(cache?.useTsHar, projectConfig.useTsHar); const tsImportSendableDiff: boolean = checkValueDiff(cache?.preTsImportSendable, tsImportSendable); const skipOhModulesLintDiff: boolean = checkValueDiff(cache?.preSkipOhModulesLint, skipOhModulesLint); const enableStrictCheckOHModuleDiff: boolean = checkValueDiff(cache?.preEnableStrictCheckOHModule, enableStrictCheckOHModule); const mixCompileDiff: boolean = checkValueDiff(cache?.preMixCompile, mixCompile); const onlyDeleteBuildInfoCache: boolean | undefined = tsImportSendableDiff || maxFlowDepthDiffers || skipOhModulesLintDiff || enableStrictCheckOHModuleDiff || mixCompileDiff || typesDiff; - const shouldRebuild: boolean | undefined = shouldRebuildForDepDiffers || targetESVersionDiffers || onlyDeleteBuildInfoCache; + const shouldInvalidCache: boolean | undefined = targetESVersionDiffers || useTsHarDiff; + const shouldRebuild: boolean | undefined = shouldRebuildForDepDiffers || shouldInvalidCache || onlyDeleteBuildInfoCache; if (reuseLanguageServiceForDepChange && hashDiffers && rollupShareObject?.depInfo?.enableIncre) { needReCheckForChangedDepUsers = true; } if (!service || shouldRebuild) { - rebuildProgram(targetESVersionDiffers, onlyDeleteBuildInfoCache); + rebuildProgram(shouldInvalidCache, onlyDeleteBuildInfoCache); service = ts.createLanguageService(servicesHost, ts.createDocumentRegistry()); } else { // Found language service from cache, update root files @@ -506,6 +509,7 @@ function getOrCreateLanguageService(servicesHost: ts.LanguageServiceHost, rootFi targetESVersion: currentTargetESVersion, types: currentTypes, maxFlowDepth: currentMaxFlowDepth, + useTsHar: projectConfig.useTsHar, preTsImportSendable: tsImportSendable, preSkipOhModulesLint: skipOhModulesLint, preMixCompile: mixCompile @@ -544,9 +548,9 @@ export function areEqualArrays(lastArray: string[] | undefined, currentArray: st return true; } -function rebuildProgram(targetESVersionDiffers: boolean | undefined, onlyDeleteBuildInfoCache: boolean | undefined): void { - if (targetESVersionDiffers) { - // If the targetESVersion is changed, we need to delete the build info cahce files +function rebuildProgram(shouldInvalidCache: boolean | undefined, onlyDeleteBuildInfoCache: boolean | undefined): void { + if (shouldInvalidCache) { + // If the targetESVersion or usTsHar is changed, we need to delete the build info cahce files & rollup caches deleteBuildInfoCache(compilerOptions.tsBuildInfoFile); targetESVersionChanged = true; } else if (onlyDeleteBuildInfoCache) { -- Gitee