From fddbfc2572a1e55b281eaccb524a23791283261f Mon Sep 17 00:00:00 2001 From: yp9522 Date: Wed, 16 Jul 2025 16:26:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A2=9E=E9=87=8F=E6=94=B6?= =?UTF-8?q?=E9=9B=86so=E4=B8=8D=E6=84=9F=E7=9F=A5=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue: https://gitee.com/openharmony/developtools_ace_ets2bundle/issues/ICMQNV Signed-off-by: yp9522 --- .../module/module_preload_file_utils.ts | 25 +++++++++++++------ .../ark_compiler/module/module_source_file.ts | 3 --- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/compiler/src/fast_build/ark_compiler/module/module_preload_file_utils.ts b/compiler/src/fast_build/ark_compiler/module/module_preload_file_utils.ts index f0eeccab3..e682df4a4 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_preload_file_utils.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_preload_file_utils.ts @@ -24,6 +24,10 @@ import { ArkTSInternalErrorDescription, ErrorCode } from '../error_code'; +import { + isCommonJsPluginVirtualFile, + isCurrentProjectFiles +} from '../utils'; interface PreloadEntry { name: string; @@ -44,9 +48,10 @@ export class PreloadFileModules { private static preloadFilePathBack: string; private static projectConfig: Object; private static logger: CommonLogger; - private static moduleIds: string[] = []; + private static rollupObject: Object | undefined; public static initialize(rollupObject: Object): void { + this.rollupObject = rollupObject; this.projectConfig = Object.assign(rollupObject.share.arkProjectConfig, rollupObject.share.projectConfig); this.logger = CommonLogger.getInstance(rollupObject); if (!this.projectConfig.isPreloadSoEnabled) { @@ -106,7 +111,7 @@ export class PreloadFileModules { } const filtered = parsed.systemPreloadHintStartupTasks.filter( - entry => !this.moduleIds.includes(entry.moduleId) + entry => this.collectModuleIds().includes(entry.moduleId) ); const merged = [...this.preloadEntriesBack, ...filtered]; @@ -175,11 +180,17 @@ export class PreloadFileModules { } } - static collectModuleIds(moduleId: string): void { - if (!this.needPreloadSo) { - return; + private static collectModuleIds(): void { + const moduleIds: string[] = []; + const entryList = this.rollupObject.getModuleIds(); + for (const moduleId of entryList) { + // exclude .d.ts|.d.ets file + if (isCommonJsPluginVirtualFile(moduleId) || !isCurrentProjectFiles(moduleId, this.projectConfig)) { + continue; + } + moduleIds.push(moduleId); } - this.moduleIds.push(moduleId); + return moduleIds; } private static ensureDirectoryExistence(filePath: string): void { @@ -196,7 +207,7 @@ export class PreloadFileModules { this.preloadFilePathBack = ''; this.logger = undefined; this.projectConfig = undefined; - this.moduleIds = []; this.needPreloadSo = true; + this.rollupObject = undefined; } } \ No newline at end of file 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 f23c161d1..b17b026dd 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 @@ -82,7 +82,6 @@ import { getDeclgenBridgeCodePath, writeBridgeCodeFileSyncByNode } from '../interop/process_arkts_evolution'; -import { PreloadFileModules } from './module_preload_file_utils'; import { isMixCompile } from '../interop/interop_manager'; import { ARKTS_1_2 } from '../interop/pre_define'; @@ -373,7 +372,6 @@ export class ModuleSourceFile { if (!rollupObject.share.projectConfig.compileHar || ModuleSourceFile.projectConfig.byteCodeHar) { //compileHar: compile closed source har of project, which convert .ets to .d.ts and js, doesn't transform module request. const eventBuildModuleSourceFile = createAndStartEvent(parentEvent, 'build module source files'); - PreloadFileModules.collectModuleIds(moduleId); await moduleSourceFile.processModuleRequest(rollupObject, eventBuildModuleSourceFile); stopEvent(eventBuildModuleSourceFile); } @@ -413,7 +411,6 @@ export class ModuleSourceFile { if (!rollupObject.share.projectConfig.compileHar || byteCodeHar) { // compileHar: compile closed source har of project, which convert .ets to .d.ts and js, doesn't transform module request. const eventBuildModuleSourceFile = createAndStartEvent(parentEvent, 'build module source files'); - PreloadFileModules.collectModuleIds(source.getModuleId()); await source.processModuleRequest(rollupObject, eventBuildModuleSourceFile); stopEvent(eventBuildModuleSourceFile); } -- Gitee