async function importPlugin(name, cwd) {
  if (isUrl(name)) {
    // @ts-expect-error -- Pass `URL` to `import()` works too
    return import(name);
  }

  if (path.isAbsolute(name)) {
    return import(pathToFileURL(name).href);
  }

  try {
    // try local files
    return await import(pathToFileURL(path.resolve(name)).href);
  } catch {
    // try node modules
    return importFromDirectory(name, cwd);
  }
}
@param {string | URL} name
@param {string} cwd