async function build()

in packages/build-plugin-lowcode/src/index.js [243:339]


async function build(options, pluginOptions, execCompile) {
  const webPackConfig = getWebpackConfig('production');
  const { context, onHook } = options;
  const { rootDir, pkg: package, userConfig = {}, commandArgs } = context;
  const { alias = {} } = userConfig;
  const {
    components,
    metaFormat,
    noParse,
    engineScope,
    metaTypes = META_TYPES,
    bundleEachComponentMeta,
    lowcodeDir = 'lowcode',
    entryPath,
    platforms = [],
    type,
    componentsPath,
  } = pluginOptions || {};
  !noParse &&
    (await initLowCodeSchema(
      rootDir,
      package,
      alias['@'] || componentsPath, // componentsPath
      metaFormat,
      metaFormat,
      components,
      engineScope === '@alilc' ? 'npm' : 'tnpm',
      lowcodeDir,
      entryPath,
    ));
  if (execCompile) {
    onHook('before.build.load', async () => {
      await babelCompile({
        source: lowcodeDir,
        rootDir,
        userOptions: userConfig,
      })
      await metaCompile({
        rootDir,
        userOptions: userConfig,
        lowcodeDir,
        package,
      });
    })
  }
  const confirmedMetaTypes = confirmMetaTypes(rootDir, lowcodeDir, metaTypes);
  const metaPaths = await Promise.all(
    confirmedMetaTypes.map((item) => {
      return bundleMetaV2(options, pluginOptions, execCompile, item);
    }),
  );
  const metaPathMap = {};
  metaPaths.forEach((item) => {    
    metaPathMap[path.basename(item).replace(path.extname(item), '')] = item;
    // metaPathMap[item.slice(item.lastIndexOf('/') + 1, item.lastIndexOf('.'))] = item;
  });
  const confirmedRenderPlatforms = confirmRenderPlatforms(rootDir, platforms);
  const renderViewPathMap = {};
  const renderViewPaths = await Promise.all(
    confirmedRenderPlatforms.map(async (item) => {
      return await bundleRenderView(options, pluginOptions, item, execCompile);
    }),
  );
  renderViewPaths.forEach((item) => {
    renderViewPathMap[path.basename(item).replace(path.extname(item), '')] = item;
    // renderViewPathMap[item.slice(item.lastIndexOf('/') + 1, item.lastIndexOf('.'))] = item;
  });
  const result = {
    metaPathMap,
    renderViewPathMap,
    platforms: confirmedRenderPlatforms,
    viewPath: await bundleEditorView(
      webPackConfig,
      options,
      pluginOptions,
      metaPathMap,
      confirmedRenderPlatforms,
      execCompile,
    ),
    assetsPaths: await bundleAssets(
      options,
      pluginOptions,
      confirmedMetaTypes,
      confirmedRenderPlatforms,
      execCompile,
    ),
  };
  if (bundleEachComponentMeta) {
    result.componentMetaPath = await bundleComponentMeta(
      webPackConfig,
      options,
      pluginOptions,
      execCompile,
    );
  }
  return result;
}