function addHook(hooks, mod, config) {
  /**
   * ESM `export default { ... }` is transpiled to:
   * module.exports = { default: { ... } };
   * First check the `default` object, and if it exists the override mod to `default`.
   */
  if (typeof mod.default === 'object') {
    mod = mod.default;
  }

  Object.keys(mod).forEach(hookType => {
    const moduleHooksArray = [].concat(mod[hookType]);

    moduleHooksArray.forEach(hook => {
      if (config && !config.includes(hook.name)) return;

      hooks[hookType] = hooks[hookType] || [];
      hooks[hookType].push(hook);
    });
  });
  return hooks;
}
Add hook from given module to list of available hooks
@private
@param {Object} hooks Object that stores information about all available hook functions grouped by the type of the hook.
@param {Object} mod Single module with object of hook functions grouped by the type of the hook
@param {Array} config List of hooks configured in template configuration