Converting a HAR to an HSP is primarily achieved by modifying the relevant configuration files. The procedure is as follows:
- In the module.json5 file of the HAR, change the value of the type field to shared and set the deliveryWithInstall field to true.
- If the HSP needs to declare navigable pages, add a pages field in the module.json5 file. Then, create a profile/main_pages.json file in the resources/base directory and set the src field.
- In the hvigorfile.ts file of the HAR, change harTasks to hspTasks.
- In the build-profile.json5 file of the HAR, remove the consumerFiles field, which is generated by default and specifies the default obfuscation rules.
After the configuration is modified, recompile the code.