107ac75b1Sopenharmony_ci/* 207ac75b1Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 307ac75b1Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 407ac75b1Sopenharmony_ci * you may not use this file except in compliance with the License. 507ac75b1Sopenharmony_ci * You may obtain a copy of the License at 607ac75b1Sopenharmony_ci * 707ac75b1Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 807ac75b1Sopenharmony_ci * 907ac75b1Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1007ac75b1Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1107ac75b1Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1207ac75b1Sopenharmony_ci * See the License for the specific language governing permissions and 1307ac75b1Sopenharmony_ci * limitations under the License. 1407ac75b1Sopenharmony_ci */ 1507ac75b1Sopenharmony_ci 1607ac75b1Sopenharmony_ciimport { initArkProjectConfig } from './common/process_ark_config'; 1707ac75b1Sopenharmony_ciimport { generateBundleAbc } from './generate_bundle_abc'; 1807ac75b1Sopenharmony_ciimport { generateModuleAbc, cleanModuleMode } from './generate_module_abc'; 1907ac75b1Sopenharmony_ciimport { transformForModule } from './transform'; 2007ac75b1Sopenharmony_ciimport { checkArkCompilerCacheInfo, shouldInvalidCache } from './cache'; 2107ac75b1Sopenharmony_ciimport { checkIfJsImportingArkts } from './check_import_module'; 2207ac75b1Sopenharmony_ciimport { cleanSharedModuleSet } from './check_shared_module'; 2307ac75b1Sopenharmony_ciimport { compilerOptions } from '../../ets_checker'; 2407ac75b1Sopenharmony_ciimport { ModuleSourceFile } from './module/module_source_file'; 2507ac75b1Sopenharmony_ciimport { SourceMapGenerator } from './generate_sourcemap'; 2607ac75b1Sopenharmony_ciimport { cleanUpUtilsObjects } from '../../ark_utils'; 2707ac75b1Sopenharmony_ciimport { cleanUpKitImportObjects } from '../../process_kit_import'; 2807ac75b1Sopenharmony_ciimport { cleanUpFilesList } from './utils'; 2907ac75b1Sopenharmony_ci 3007ac75b1Sopenharmony_ciexport function genAbc() { 3107ac75b1Sopenharmony_ci return { 3207ac75b1Sopenharmony_ci name: 'genAbc', 3307ac75b1Sopenharmony_ci buildStart() { 3407ac75b1Sopenharmony_ci this.share.arkProjectConfig = initArkProjectConfig(this.share); 3507ac75b1Sopenharmony_ci checkArkCompilerCacheInfo(this); 3607ac75b1Sopenharmony_ci //Because calling the method of SourceMapGenerator may not retrieve the rollupObject 3707ac75b1Sopenharmony_ci //it is necessary to assign the rollupObject to SourceMapGenerator in the early stages of build 3807ac75b1Sopenharmony_ci SourceMapGenerator.init(this); 3907ac75b1Sopenharmony_ci }, 4007ac75b1Sopenharmony_ci shouldInvalidCache: shouldInvalidCache, 4107ac75b1Sopenharmony_ci transform: transformForModule, 4207ac75b1Sopenharmony_ci beforeBuildEnd: { 4307ac75b1Sopenharmony_ci // [pre] means this handler running in first at the stage of beforeBuildEnd. 4407ac75b1Sopenharmony_ci order: 'pre', 4507ac75b1Sopenharmony_ci handler() { 4607ac75b1Sopenharmony_ci if (compilerOptions.needDoArkTsLinter) { 4707ac75b1Sopenharmony_ci checkIfJsImportingArkts(this); 4807ac75b1Sopenharmony_ci } 4907ac75b1Sopenharmony_ci if (this.share.projectConfig.needCoverageInsert) { 5007ac75b1Sopenharmony_ci this.share.ModuleSourceFile = ModuleSourceFile.getSourceFiles(); 5107ac75b1Sopenharmony_ci } 5207ac75b1Sopenharmony_ci } 5307ac75b1Sopenharmony_ci }, 5407ac75b1Sopenharmony_ci buildEnd: generateModuleAbc, 5507ac75b1Sopenharmony_ci generateBundle: generateBundleAbc, 5607ac75b1Sopenharmony_ci cleanUp: () => { 5707ac75b1Sopenharmony_ci SourceMapGenerator.cleanSourceMapObject(); 5807ac75b1Sopenharmony_ci cleanUpUtilsObjects(); 5907ac75b1Sopenharmony_ci cleanUpKitImportObjects(); 6007ac75b1Sopenharmony_ci cleanUpFilesList(); 6107ac75b1Sopenharmony_ci cleanModuleMode(); 6207ac75b1Sopenharmony_ci ModuleSourceFile.cleanUpObjects(); 6307ac75b1Sopenharmony_ci cleanSharedModuleSet(); 6407ac75b1Sopenharmony_ci } 6507ac75b1Sopenharmony_ci }; 6607ac75b1Sopenharmony_ci} 67