Fix Webpack modules that are not arrow funcs, Part II

This commit is contained in:
Vendicated 2022-11-01 15:06:15 +01:00
parent 64aed87de4
commit 13c73699e9
No known key found for this signature in database
GPG Key ID: EC781ADFB93EFFA3

@ -58,9 +58,9 @@ function patchPush() {
// cause issues. // cause issues.
let code: string = mod.toString().replaceAll("\n", ""); let code: string = mod.toString().replaceAll("\n", "");
// a very small minority of modules use function() instead of arrow functions, // a very small minority of modules use function() instead of arrow functions,
// but, unnamed toplevel functions aren't valid. Thus, give those a name // but, unnamed toplevel functions aren't valid. However 0, function() makes it a statement
if (code.startsWith("function(")) { if (code.startsWith("function(")) {
code = "function patchedModule" + code.slice("function".length); code = "0," + code;
} }
const originalMod = mod; const originalMod = mod;
const patchedBy = new Set(); const patchedBy = new Set();