From 0da25ddc23596595f1e884649e1ab59095f88053 Mon Sep 17 00:00:00 2001 From: c00513733 Date: Sun, 14 Jan 2024 12:32:14 +0000 Subject: [PATCH] Clean up ModuleSourceFile object Issue: https://gitee.com/openharmony/developtools_ace_ets2bundle/issues/I8W0KY Signed-off-by: c00513733 Change-Id: If04c19fc38fd29cfc82a62d1eac3f68dae3d756a --- .../ark_compiler/module/module_source_file.ts | 16 +++++++++++++--- compiler/src/fast_build/ark_compiler/utils.ts | 2 ++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts index 97a2c37e8..0f8321d69 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts @@ -35,7 +35,7 @@ import { updateSourceMap, writeFileContentToTempDir } from '../utils'; -import { +import { toUnixPath, createAndStartEvent, stopEvent @@ -306,7 +306,7 @@ export class ModuleSourceFile { const moduleInfo: any = rollupObject.getModuleInfo(this.moduleId); const importMap: any = moduleInfo.importedIdMaps; const code: MagicString = new MagicString(this.source); - // The data collected by moduleNodeMap represents the node dataset of related types. + // The data collected by moduleNodeMap represents the node dataset of related types. // The data is processed based on the AST collected during the transform stage. const moduleNodeMap: Map = moduleInfo.getNodeByType(ROLLUP_IMPORT_NODE, ROLLUP_EXPORTNAME_NODE, ROLLUP_EXPORTALL_NODE, @@ -322,7 +322,7 @@ export class ModuleSourceFile { } if ((node.type === ROLLUP_IMPORT_NODE || node.type === ROLLUP_EXPORTNAME_NODE || node.type === ROLLUP_EXPORTALL_NODE && node.source)) { - const ohmUrl: string | undefined = + const ohmUrl: string | undefined = this.getOhmUrl(rollupObject, node.source.value, importMap[node.source.value]); if (ohmUrl !== undefined) { code.update(node.source.start, node.source.end, `'${ohmUrl}'`); @@ -451,4 +451,14 @@ export class ModuleSourceFile { public static sortSourceFilesByModuleId(): void { ModuleSourceFile.sourceFiles.sort((a, b) => a.moduleId.localeCompare(b.moduleId)); } + + public static cleanUpObjects(): void { + ModuleSourceFile.sourceFiles = []; + ModuleSourceFile.projectConfig = undefined; + ModuleSourceFile.logger = undefined; + ModuleSourceFile.mockConfigInfo = {}; + ModuleSourceFile.mockFiles = []; + ModuleSourceFile.newMockConfigInfo = {}; + ModuleSourceFile.needProcessMock = false; + } } diff --git a/compiler/src/fast_build/ark_compiler/utils.ts b/compiler/src/fast_build/ark_compiler/utils.ts index 1aac35ee7..37a7a10e1 100644 --- a/compiler/src/fast_build/ark_compiler/utils.ts +++ b/compiler/src/fast_build/ark_compiler/utils.ts @@ -50,6 +50,7 @@ import { hasTsNoCheckOrTsIgnoreFiles, compilingEtsOrTsFiles } from '../../proces import { cleanSourceMapObject } from './transform'; import { cleanUpKitImportObjects } from '../../process_kit_import'; import { cleanModuleMode } from './generate_module_abc'; +import { ModuleSourceFile } from './module/module_source_file'; export function needAotCompiler(projectConfig: any): boolean { return projectConfig.compileMode === ESMODULE && (projectConfig.anBuildMode === AOT_FULL || @@ -240,6 +241,7 @@ export function cleanUpObjects(): void { cleanUpUtilsObjects(); cleanUpKitImportObjects(); cleanModuleMode(); + ModuleSourceFile.cleanUpObjects(); } export const utUtils = { -- Gitee