Remove obsolete webpack hacks
This commit is contained in:
parent
9efc0ff579
commit
6f05612e34
1 changed files with 5 additions and 11 deletions
|
@ -119,12 +119,9 @@ function patchFactories(factories: Record<string | number, (module: { exports: a
|
||||||
// Additionally, `[actual newline]` is one less char than "\n", so if Discord
|
// Additionally, `[actual newline]` is one less char than "\n", so if Discord
|
||||||
// ever targets newer browsers, the minifier could potentially use this trick and
|
// ever targets newer browsers, the minifier could potentially use this trick and
|
||||||
// cause issues.
|
// cause issues.
|
||||||
let code: string = mod.toString().replaceAll("\n", "");
|
//
|
||||||
// a very small minority of modules use function() instead of arrow functions,
|
// 0, prefix is to turn it into an expression: 0,function(){} would be invalid syntax without the 0,
|
||||||
// but, unnamed toplevel functions aren't valid. However 0, function() makes it a statement
|
let code: string = "0," + mod.toString().replaceAll("\n", "");
|
||||||
if (code.startsWith("function(")) {
|
|
||||||
code = "0," + code;
|
|
||||||
}
|
|
||||||
const originalMod = mod;
|
const originalMod = mod;
|
||||||
const patchedBy = new Set();
|
const patchedBy = new Set();
|
||||||
|
|
||||||
|
@ -182,10 +179,8 @@ function patchFactories(factories: Record<string | number, (module: { exports: a
|
||||||
|
|
||||||
// for some reason throws some error on which calling .toString() leads to infinite recursion
|
// for some reason throws some error on which calling .toString() leads to infinite recursion
|
||||||
// when you force load all chunks???
|
// when you force load all chunks???
|
||||||
try {
|
|
||||||
factory.toString = () => mod.toString();
|
factory.toString = () => mod.toString();
|
||||||
factory.original = originalMod;
|
factory.original = originalMod;
|
||||||
} catch { }
|
|
||||||
|
|
||||||
for (let i = 0; i < patches.length; i++) {
|
for (let i = 0; i < patches.length; i++) {
|
||||||
const patch = patches[i];
|
const patch = patches[i];
|
||||||
|
@ -210,7 +205,6 @@ function patchFactories(factories: Record<string | number, (module: { exports: a
|
||||||
const newCode = executePatch(replacement.match, replacement.replace as string);
|
const newCode = executePatch(replacement.match, replacement.replace as string);
|
||||||
if (newCode === code) {
|
if (newCode === code) {
|
||||||
if (!patch.noWarn) {
|
if (!patch.noWarn) {
|
||||||
(window.explosivePlugins ??= new Set<string>()).add(patch.plugin);
|
|
||||||
logger.warn(`Patch by ${patch.plugin} had no effect (Module id is ${id}): ${replacement.match}`);
|
logger.warn(`Patch by ${patch.plugin} had no effect (Module id is ${id}): ${replacement.match}`);
|
||||||
if (IS_DEV) {
|
if (IS_DEV) {
|
||||||
logger.debug("Function Source:\n", code);
|
logger.debug("Function Source:\n", code);
|
||||||
|
|
Loading…
Reference in a new issue