function loader(value, callback) {
  const options = /** @type {CompileOptions} */ (this.getOptions())
  const hash = getOptionsHash(options)
  const config = {
    SourceMapGenerator: this.sourceMap ? SourceMapGenerator : undefined,
    development: this.mode === 'development',
    ...options
  }
  /* c8 ignore next -- some loaders set `undefined` (see `TypeStrong/ts-loader`). */
  const compiler = this._compiler || marker

  // To do: next major: remove.
  if ('renderer' in config) {
    callback(
      new Error(
        '`options.renderer` is no longer supported. Please see <https://mdxjs.com/migrating/v2/> for more information'
      )
    )
    return
  }

  let map = cache.get(compiler)

  if (!map) {
    map = new Map()
    cache.set(compiler, map)
  }

  let process = map.get(hash)

  if (!process) {
    process = createFormatAwareProcessors(config).process
    map.set(hash, process)
  }

  const context = this.context
  const filePath = this.resourcePath

  process({value, path: filePath}).then(
    function (file) {
      callback(
        undefined,
        // @ts-expect-error: seems to be `@types/node` bug that suddenly started
        // to error.
        Buffer.from(file.value),
        // @ts-expect-error: `webpack` is not compiled with `exactOptionalPropertyTypes`,
        // so it does not allow `sourceRoot` in `file.map` to be `undefined` here.
        file.map || undefined
      )
    },
    /**
     * @param {VFileMessage} error
     *   Error.
     * @returns {undefined}
     *   Nothing.
     */
    function (error) {
      const fpath = path.relative(context, filePath)
      error.message = `${fpath}:${error.name}: ${error.message}`
      callback(error)
    }
  )
}
A Webpack (5+) loader for MDX.
See `webpack.cjs`, which wraps this, because Webpack loaders must currently
be CommonJS.

@this {LoaderContext<unknown>}
  Context.
@param {string} value
  Value.
@param {LoaderContext<unknown>['callback']} callback
  Callback.
@returns {undefined}
  Nothing.