From 58758d694289a3877423948bf1176f4fd05f8183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=95=E7=BB=B4=E5=89=8D?= Date: Wed, 20 Aug 2025 16:41:26 +0800 Subject: [PATCH] Fix for widget cards overwriting the cache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue: https://gitee.com/openharmony/developtools_ace_ets2bundle/issues/ICTVXB Signed-off-by: 单维前 --- compiler/src/ets_checker.ts | 6 ++++-- compiler/src/interop/src/ets_checker.ts | 6 ++++-- compiler/test/ark_compiler_ut/ets_checker.test.ts | 12 ++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index 716d75244..8aaec8d56 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -177,7 +177,8 @@ function setCompilerOptions(resolveModulePaths: string[]): void { allPath.push('../*'); } } - const suffix: string = projectConfig.hotReload ? HOT_RELOAD_BUILD_INFO_SUFFIX : TS_BUILD_INFO_SUFFIX; + const suffix: string = projectConfig?.hotReload ? HOT_RELOAD_BUILD_INFO_SUFFIX : + `${TS_BUILD_INFO_SUFFIX}${projectConfig?.widgetCompile === 'true' ? '_widget' : ''}`; const buildInfoPath: string = path.resolve(projectConfig.cachePath, '..', suffix); checkArkTSVersion(); Object.assign(compilerOptions, { @@ -568,7 +569,8 @@ export function serviceChecker(rootFileNames: string[], newLogger: Object = null MemoryMonitor.stopRecordStage(recordInfo); props = languageService.getProps(); } else { - cacheFile = path.resolve(projectConfig.cachePath, '../.ts_checker_cache'); + cacheFile = rollupShareObject?.projectConfig?.widgetCompile === 'true' ? path.resolve(projectConfig.cachePath, '../.ts_checker_cache_widget') : + path.resolve(projectConfig.cachePath, '../.ts_checker_cache'); const [isJsonObject, cacheJsonObject]: [boolean, WholeCache | undefined] = isJsonString(cacheFile); const wholeCache: WholeCache = isJsonObject ? cacheJsonObject : { 'runtimeOS': projectConfig.runtimeOS, 'sdkInfo': projectConfig.sdkInfo, 'fileList': {} }; if (wholeCache.runtimeOS === projectConfig.runtimeOS && wholeCache.sdkInfo === projectConfig.sdkInfo) { diff --git a/compiler/src/interop/src/ets_checker.ts b/compiler/src/interop/src/ets_checker.ts index e1d5381b3..92393f8db 100644 --- a/compiler/src/interop/src/ets_checker.ts +++ b/compiler/src/interop/src/ets_checker.ts @@ -193,7 +193,8 @@ function setCompilerOptions(resolveModulePaths: string[]): void { if (isMixCompile()) { compilerOptions.preserveValueImports = true; } - const suffix: string = projectConfig.hotReload ? HOT_RELOAD_BUILD_INFO_SUFFIX : TS_BUILD_INFO_SUFFIX; + const suffix: string = projectConfig?.hotReload ? HOT_RELOAD_BUILD_INFO_SUFFIX : + `${TS_BUILD_INFO_SUFFIX}${projectConfig?.widgetCompile === 'true' ? '_widget' : ''}`; const buildInfoPath: string = path.resolve(projectConfig.cachePath, '..', suffix); checkArkTSVersion(); Object.assign(compilerOptions, { @@ -588,7 +589,8 @@ export function serviceChecker(rootFileNames: string[], newLogger: Object = null MemoryMonitor.stopRecordStage(recordInfo); props = languageService.getProps(); } else { - cacheFile = path.resolve(projectConfig.cachePath, '../.ts_checker_cache'); + cacheFile = rollupShareObject?.projectConfig?.widgetCompile === 'true' ? path.resolve(projectConfig.cachePath, '../.ts_checker_cache_widget') : + path.resolve(projectConfig.cachePath, '../.ts_checker_cache'); const [isJsonObject, cacheJsonObject]: [boolean, WholeCache | undefined] = isJsonString(cacheFile); const wholeCache: WholeCache = isJsonObject ? cacheJsonObject : { 'runtimeOS': projectConfig.runtimeOS, 'sdkInfo': projectConfig.sdkInfo, 'fileList': {} }; if (wholeCache.runtimeOS === projectConfig.runtimeOS && wholeCache.sdkInfo === projectConfig.sdkInfo) { diff --git a/compiler/test/ark_compiler_ut/ets_checker.test.ts b/compiler/test/ark_compiler_ut/ets_checker.test.ts index 17d258b70..b0dceb320 100644 --- a/compiler/test/ark_compiler_ut/ets_checker.test.ts +++ b/compiler/test/ark_compiler_ut/ets_checker.test.ts @@ -60,17 +60,29 @@ mocha.describe('test ets_checker file api', function () { mocha.after(() => { delete this.rollup; const cacheFile: string = path.resolve(projectConfig.cachePath, '../.ts_checker_cache'); + const cacheFileWidget: string = path.resolve(projectConfig.cachePath, '../.ts_checker_cache_widget'); if (fs.existsSync(cacheFile)) { fs.unlinkSync(cacheFile); } + if (fs.existsSync(cacheFileWidget)) { + fs.unlinkSync(cacheFileWidget); + } const tsBuildInfoFilePath: string = path.resolve(projectConfig.cachePath, '..', TS_BUILD_INFO_SUFFIX); + const tsBuildInfoWidgetFilePath: string = path.resolve(projectConfig.cachePath, '..', TS_BUILD_INFO_SUFFIX + '_widget'); if (fs.existsSync(tsBuildInfoFilePath)) { fs.unlinkSync(tsBuildInfoFilePath); } + if (fs.existsSync(tsBuildInfoWidgetFilePath)) { + fs.unlinkSync(tsBuildInfoWidgetFilePath); + } const tsBuildInfoLinterFilePath: string = tsBuildInfoFilePath + '.linter'; + const tsBuildInfoWidgetLinterFilePath: string = tsBuildInfoWidgetFilePath + '.linter'; if (fs.existsSync(tsBuildInfoLinterFilePath)) { fs.unlinkSync(tsBuildInfoLinterFilePath); } + if (fs.existsSync(tsBuildInfoWidgetLinterFilePath)) { + fs.unlinkSync(tsBuildInfoWidgetLinterFilePath); + } }); mocha.it('1-1: test addLocalPackageSet for original ohmurl', function () { -- Gitee