async requireServicePlugin(
    serviceDir,
    pluginListedName,
    legacyLocalPluginsPath,
  ) {
    const logger = log.get('sls:plugins:load')

    const require = async (dir, module) => {
      try {
        const require = createRequire(path.resolve(dir, 'require-resolver'))
        return require.resolve(module)
      } catch (error) {
        logger.debug(
          `Failed to resolve path for module ${module} from ${dir} due to '${error}'`,
        )
        return null
      }
    }

    /**
     * Check the Service directory for the plugin.
     * This will check in the node_modules of the service directory
     * and in the service directory itself.
     */
    const localPluginPath = await require(serviceDir, pluginListedName)
    if (localPluginPath) {
      return await import(pathToFileURL(localPluginPath))
    }

    /**
     * Search in the Framework's node_modules
     */
    const externalPluginPath = await require(fileURLToPath(
      import.meta.url,
    ), pluginListedName)
    if (!externalPluginPath) {
      throw new ServerlessError(
        `Serverless plugin "${pluginListedName}" not found.`,
        'PLUGIN_NOT_FOUND',
      )
    }
    return await import(pathToFileURL(externalPluginPath))
  }
Return a promise to require a Service plugin, whether it's local in a relative path,
local in the service directory, or a node_module
@param {*} serviceDir
@param {*} pluginListedName
@param {*} legacyLocalPluginsPath
@returns