目录

Building a Project into the ASCF Paradigm Using a Third-Party Framework (Such as uni-app and Taro)

Currently, some third-party frameworks can be used to build projects into atomic services through ASCF.

Building uni-app Projects into Atomic Services

uni-app can be used to build projects into ASCF atomic services since HBuilderX 4.34.

[h2]CLI

For a new CLI project, run the following command in the terminal to create a project:

npx degit dcloudio/uni-preset-vue#vite-alpha my-vue3-project

# Development
npm run dev:mp-harmony

# Build
npm run build:mp-harmony

For an existing CLI project, run the following command in the terminal to upgrade to the latest alpha dependencies:

npx @dcloudio/uvm@latest alpha

Modify scripts in the package.json file and add the following content:

{
  "dev:mp-harmony": "uni -p mp-harmony",
  "build:mp-harmony": "uni build -p mp-harmony"
}

For details, please refer to the example of creating a project using the CLI provided by uni-app.

[h2]GUI

For a new project created via the GUI, complete initialization by referring to Quick Start on the official website of uni-app.

For an existing project, perform the conversion by referring to the HarmonyOS atomic service guide on the official website of uni-app.

Community practice case: building projects into ASCF projects using uni-app.

Building Taro Projects into Atomic Services

Taro 3.6.38 and later versions, as well as Taro 4.X, support building projects into ASCF atomic services.

For a new project, complete initialization by referring to the quick start guide on template creation provided by Taro.

Select the ASCF template.

After the project is initialized, modify the config/index.{js,ts} file in the Taro project by changing outputRoot: 'dist/ascf' to outputRoot: process.env.TARO_ENV === 'ascf' ? 'ascf-project/ascf/ascf_src' : 'dist', where outputRoot is the path of the created ASCF project. For details, please refer to Creating an ASCF Project.

For an existing project, perform conversion by referring to the example on compilation and running provided by Taro.

Then run the following command in the terminal to start development.

npm run dev:ascf

# Open another terminal.
npm run watch:ascf

Community practice case: Converting Taro to ASCF

You are advised to adapt your project to an atomic service by following the instructions below:

  1. Understand the project code, familiarize yourself with the current page layout and features, review the API calls and page processing logic, and sort out a list of components and APIs.

  2. Use the MP-HARMONY conditional compilation mode to adapt the project to an atomic service.

  3. Follow the instructions in Development Guide to implement necessary adaptations. Then build the project into the ASCF paradigm, copy the build artifact dist/build/mp-harmony to the ascf/ascf_src directory, and debug and run the project by referring to the Hello ASCF project.

Using Other Third-Party Frameworks

Third-party frameworks can be adapted to support atomic services based on ASCF which adopts a mini-program-like paradigm. To use a third-party framework to develop atomic services, send your request to the following email address. Huawei operations personnel will contact you within 1 to 3 working days.

Email address: atomicservice@huawei.com

Email subject: [Requirements for adapting third-party frameworks to atomic services via ASCF]-[Atomic service name]-[App ID]-[Developer ID]. For details about how to query the app ID, please refer to the following table.

Email content: Describe your request in detail.

Basic Information Description
Atomic service name Name of the atomic service to be released on AppGallery.
APP ID App ID. You can find it by signing in to HUAWEI Developers and choosing My Projects > Settings > Regular > App > APP ID.
Developer ID HUAWEI ID used by you for debugging. To obtain the HUAWEI ID, sign in to HUAWEI Developers and choose My Projects > Settings > Regular > Developer > Developer ID.