function getAmpValidatorInstance(
  /** @type {string | undefined} */ validatorPath
) {
  let promise = instancePromises.get(validatorPath)
  if (!promise) {
    // NOTE: if `validatorPath` is undefined, `AmpHtmlValidator` will load the code from its default URL
    promise = AmpHtmlValidator.getInstance(validatorPath)
    instancePromises.set(validatorPath, promise)
  }
  return promise
}
This is a workaround for issues with concurrent `AmpHtmlValidator.getInstance()` calls,
duplicated from 'packages/next/src/export/helpers/get-amp-html-validator.ts'.
see original code for explanation.

@returns {Promise<Validator>}