1# Converting HAR to HSP
2Currently, the HAR has a problem with duplicate packaging, leading an oversize application package. To fix this problem, you can convert the HAR to the HSP through by the configuration items.
3## How to Convert
4
51. Change the value of **type** to **shared** and add the **deliveryWithInstall** and **pages** field in the **module.json5** file of the HAR module.
6    ```json
7    // MyApplication\library\src\main\module.json5
8    {
9      "module": {
10        "type": "shared",
11        "deliveryWithInstall": true,
12        "pages": "$profile:main_pages"
13        // ...
14      }
15    }
16    ```
17
182. Add a string field **shared_desc** in **element** of the **base**, **en\_US**, and **zh\_CN** qualifiers directories under the **resources** directory.
19    ```json
20    // MyApplication\library\src\main\resources\base\element\string.json
21    {
22      "string": [
23        {
24          "name": "shared_desc",
25          "value": "description"
26        }
27      ]
28    }
29    ```
30
313. Add a **profile** folder in **resources** > **base**. Then add a **main_pages.json** file to the added folder and configure it as follows:
32    ```json
33    // MyApplication\library\src\main\resources\base\profile\main_pages.json
34    {
35      "src": [
36        "pages/PageIndex"
37      ]
38    }
39    ```
40
414. Add a **pages** directory in the **ets** directory. Then add a **PageIndex.ets** file in the added directory and configure it as follows:
42    ```ts
43    // MyApplication\library\src\main\ets\pages\PageIndex.ets
44    @Entry
45    @Component
46    struct PageIndex {
47      @State message: string = 'hello world';
48
49      build() {
50        Row() {
51          Column() {
52            Text(this.message)
53              .fontSize(50)
54              .fontWeight(FontWeight.Bold)
55          }
56          .width('100%')
57        }
58        .height('100%')
59      }
60    }
61    ```
62
635. Delete the **consumerFiles** field from the **build-profile.json5** file of the HAR module.
64
656. Replace the content in the **hvigorfile.ts** file of the HAR module with the following content:
66    ```ts
67    // MyApplication\library\hvigorfile.ts
68    import { hspTasks } from '@ohos/hvigor-ohos-plugin';
69
70    export default {
71      system: hspTasks,  /* Built-in plugin of Hvigor. It cannot be modified. */
72      plugins:[]         /* Custom plugin to extend the functionality of Hvigor. */
73    }
74    ```
75
767. Add the **packageType** field in the **oh-package.json5** file.
77    ```json
78    // MyApplication\library\oh-package.json5
79    {
80      "packageType": "InterfaceHar"
81    }
82    ```
83
848. Add the **targets** tag to **build-profile.json5** > **modules** > **library** in the root directory of the project.
85
86    ```json
87    // MyApplication\build-profile.json5
88    "modules": [
89      {
90        "name": "library",
91        "srcPath": "./library",
92        "targets": [
93          {
94            "name": "default",
95            "applyToProducts": [
96              "default"
97            ]
98          }
99        ]
100      }
101    ]
102