OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

this in an IIFE is undefined when building with vite

  • Thread starter Thread starter pailhead
  • Start date Start date
P

pailhead

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

Code:
var requestFrame = (function () {
  var window = this
  var raf = window.requestAnimationFrame ||
  //...and so on and so forth
})()

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.

<p>I have tried to migrate a CRA to vite. One remaining obstacle is a dependency of a dependency that has this code:</p>
<pre><code>var requestFrame = (function () {
var window = this
var raf = window.requestAnimationFrame ||
//...and so on and so forth
})()
</code></pre>
<p><code>this</code> is <code>undefined</code> and the first thing it tries to invoke (<code>requestAnimationFrame</code>) 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.</p>
 
Top