• 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 { JSBUNDLE } from './common/ark_define';
17import { BundlePreviewMode } from './bundle/bundle_preview_mode';
18import { BundleBuildMode } from './bundle/bundle_build_mode';
19
20/**
21 * rollup generatebundle hook
22 * @param {rollup OutputOptions} options
23 * @param {rollup [fileName: string]: AssetInfo | ChunkInfo} bundle
24 * @param {boolean} isWrite
25 */
26export function generateBundleAbc(options: any, bundle: any, isWrite: boolean) {
27  if (bundle === null || this.share.projectConfig.compileMode !== JSBUNDLE) {
28    return;
29  }
30
31  generateAbc(this, bundle);
32}
33
34function generateAbc(rollupObject: any, rollupBundleFileSet: any) {
35  if (rollupObject.share.projectConfig.watchMode === 'true') {
36    const bundlePreviewMode: BundlePreviewMode = new BundlePreviewMode(rollupObject, rollupBundleFileSet);
37    bundlePreviewMode.generateAbc();
38  } else {
39    const bundleBuildMode: BundleBuildMode = new BundleBuildMode(rollupObject, rollupBundleFileSet);
40    bundleBuildMode.generateAbc();
41  }
42}
43