You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In minified code, webpackRequireName will often be a single-character function name like r, so this regex will detect all occurrences of r(…). Unfortuantely, the r() function name may also be used in other scopes for a totally different function, so this dependency detection can pick up a totally random argument and treat it as a dependency.
In our case (as users of hls.min.js) this function call is minified to r('init', null), and so 'init' is erroneously detected as a dependency.
Ordinarily this fails silently and doesn't affect functionality. When assembling the WebWorker blob, for id='init', the call to sources.main[id] returns undefined and things carry on without raising any errors. However, if there is variable/function defined on the Array class with the name init, then it will be returned, stringified, and lead to a syntax error in the Worker. (In our case, that init function is added to the Array prototype by ember.js)
So, with both of those very unlucky circumstances, we end up with this when the Worker is initialized:
I imagine a robust fix to the dependency-detection will be tricky - parsing JS with Regex is naturally not going to be perfect. But I wonder if it might be possible to mitigate the errors when it does happen 🤔
The text was updated successfully, but these errors were encountered:
This library attempts to find dependencies using a regular expression:
webworkify-webpack/index.js
Lines 97 to 103 in 2e7827d
In minified code,
webpackRequireName
will often be a single-character function name liker
, so this regex will detect all occurrences ofr(…)
. Unfortuantely, ther()
function name may also be used in other scopes for a totally different function, so this dependency detection can pick up a totally random argument and treat it as a dependency.In our case (as users of
hls.min.js
) this function call is minified tor('init', null)
, and so'init'
is erroneously detected as a dependency.Ordinarily this fails silently and doesn't affect functionality. When assembling the WebWorker blob, for
id='init'
, the call tosources.main[id]
returnsundefined
and things carry on without raising any errors. However, if there is variable/function defined on theArray
class with the nameinit
, then it will be returned, stringified, and lead to a syntax error in the Worker. (In our case, thatinit
function is added to the Array prototype by ember.js)So, with both of those very unlucky circumstances, we end up with this when the Worker is initialized:
I imagine a robust fix to the dependency-detection will be tricky - parsing JS with Regex is naturally not going to be perfect. But I wonder if it might be possible to mitigate the errors when it does happen 🤔
The text was updated successfully, but these errors were encountered: