• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { initArkProjectConfig } from './common/process_ark_config';
17import { generateBundleAbc } from './generate_bundle_abc';
18import { generateModuleAbc } from './generate_module_abc';
19import { transformForModule } from './transform';
20import { cleanUpObjects } from './utils';
21import { checkArkCompilerCacheInfo, shouldInvalidCache } from './cache';
22import { checkIfJsImportingArkts } from './check_import_module';
23import { compilerOptions } from '../../ets_checker';
24import { ModuleSourceFile } from './module/module_source_file';
25
26export function genAbc() {
27  return {
28    name: 'genAbc',
29    buildStart() {
30      this.share.arkProjectConfig = initArkProjectConfig(this.share);
31      checkArkCompilerCacheInfo(this);
32    },
33    shouldInvalidCache: shouldInvalidCache,
34    transform: transformForModule,
35    beforeBuildEnd: {
36      // [pre] means this handler running in first at the stage of beforeBuildEnd.
37      order: 'pre',
38      handler() {
39        if (compilerOptions.needDoArkTsLinter) {
40          checkIfJsImportingArkts(this);
41        }
42        if (this.share.projectConfig.needCoverageInsert) {
43          this.share.ModuleSourceFile = ModuleSourceFile.getSourceFiles();
44        }
45      }
46    },
47    buildEnd: generateModuleAbc,
48    generateBundle: generateBundleAbc,
49    cleanUp: cleanUpObjects
50  };
51}
52