importFunction = async (handlerFileAbsolutePath, handlerName) => {
  // Check if the file exists
  if (!fs.existsSync(handlerFileAbsolutePath)) {
    throw new Error(`Handler file was not found: ${handlerFileAbsolutePath}`)
  }

  // Convert the file path to a file URL to ensure
  // it works across different operating systems
  // and for both CommonJS and ESM handler files
  const fileUrl = pathToFileURL(handlerFileAbsolutePath).href

  // Import the handler file. This works for both CommonJS and ESM handler files
  const handlerFunction = (await import(fileUrl))[handlerName]

  // Make sure the handler is a function
  if (typeof handlerFunction !== 'function') {
    throw new Error(`Handler is not a function`)
  }

  // return the function to be invoked
  return handlerFunction
}
Imports the user handler function from the specified file path.
This supports both CommonJS and ESM handler files.

@param {string} handlerFileAbsolutePath - Path to handler file
@param {string} handlerName - The Handler Name defined in the config file
@returns {Promise<Function>}