1# Converting HAR to HSP 2<!--Kit: Ability Kit--> 3<!--Subsystem: BundleManager--> 4<!--Owner: @wanghang904--> 5<!--Designer: @hanfeng6--> 6<!--Tester: @kongjing2--> 7<!--Adviser: @Brilliantry_Rui--> 8 9Currently, 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 by changing the configuration items. 10## How to Convert 11 121. Set **type** to **shared** and add the **deliveryWithInstall** and **pages** fields in the **module.json5** file of the HAR module. 13 ```json 14 // MyApplication\library\src\main\module.json5 15 { 16 "module": { 17 "type": "shared", 18 "deliveryWithInstall": true, 19 "pages": "$profile:main_pages" 20 // ... 21 } 22 } 23 ``` 24 252. Create a **profile** folder in the **resources\base** directory. Then add the **main_pages.json** file to the created folder and configure it as follows: 26 ```json 27 // MyApplication\library\src\main\resources\base\profile\main_pages.json 28 { 29 "src": [ 30 "pages/PageIndex" 31 ] 32 } 33 ``` 34 353. Create a **pages** folder in the **ets** directory. Then add the **PageIndex.ets** file to the created folder and configure it as follows: 36 ```ts 37 // MyApplication\library\src\main\ets\pages\PageIndex.ets 38 @Entry 39 @Component 40 struct PageIndex { 41 @State message: string = 'hello world'; 42 43 build() { 44 Row() { 45 Column() { 46 Text(this.message) 47 .fontSize(50) 48 .fontWeight(FontWeight.Bold) 49 } 50 .width('100%') 51 } 52 .height('100%') 53 } 54 } 55 ``` 56 574. Delete the **consumerFiles** field from the **build-profile.json5** file of the HAR module. 58 595. Replace the content in the **hvigorfile.ts** file of the HAR module with the following content: 60 ```ts 61 // MyApplication\library\hvigorfile.ts 62 import { hspTasks } from '@ohos/hvigor-ohos-plugin'; 63 64 export default { 65 system: hspTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ 66 plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ 67 } 68 ``` 69 706. Add the **packageType** field in the **oh-package.json5** file. 71 ```json 72 // MyApplication\library\oh-package.json5 73 { 74 "packageType": "InterfaceHar" 75 } 76 ``` 77 787. Add the **targets** tag to **build-profile.json5** > **modules** > **library** in the root directory of the project. 79 80 ```json 81 // MyApplication\build-profile.json5 82 "modules": [ 83 { 84 "name": "library", 85 "srcPath": "./library", 86 "targets": [ 87 { 88 "name": "default", 89 "applyToProducts": [ 90 "default" 91 ] 92 } 93 ] 94 } 95 ] 96