this in an IIFE is undefined when building with vite

I have tried to migrate a CRA to vite. One remaining obstacle is a dependency of a dependency that has this code:

var requestFrame = (function () {
  var window = this
  var raf = window.requestAnimationFrame ||
    window.mozRequestAnimationFrame ||
    window.webkitRequestAnimationFrame ||
    function fallbackRAF(func) {
      return window.setTimeout(func, 20)
    }
  return function requestFrameFunction(func) {
    return raf(func)
  }
})()

this is undefined and the first thing it tries to invoke (requestAnimationFrame) throws. The page, depending on a dependency that depends on this seems to have worked fine before so I’m suspecting that something can be configured in vite to fix this, but i’m not sure what to be looking for.