Which snippet works correctly when updating the package.json file to point to the hook file for a cartridge?
The cartridge's root-levelpackage.jsonuses the'hooks'property to point to the hook registration file. In the standard SFRA cartridge structure, the hook-registration file resides under:
cartridge/scripts/hooks.json
Therefore, the correct relative path is:
{'hooks':'./cartridge/scripts/hooks.json'}
Salesforce's SFRA hook documentation confirms thatpackage.jsonuses thehookskeyword to identify the hook file and that the referenced hook file then maps extension-point names to script implementations.
Option B omits thecartridgeportion of the normal directory structure, so it points to the wrong location. Option C uses JavaScript-object syntax rather than valid JSON because thehooksproperty name is unquoted. Apackage.jsonfile must contain valid JSON.
Thehooks.jsonfile contains entries with the extension-pointnameand correspondingscriptmodule. Once the cartridge is deployed and active on the appropriate cartridge path, registered hooks can participate in storefront or platform extension points.
Study Guide reference:Application Development --- hook registration,package.json,hooks.json, cartridge structure, CommonJS hook modules, and extension points.
===============
Florinda
1 day agoKeith
7 days ago