aboutsummaryrefslogtreecommitdiff
path: root/src/webpack/patchWebpack.ts
diff options
context:
space:
mode:
authorJustice Almanzar <superdash993@gmail.com>2022-12-19 17:59:54 -0500
committerGitHub <noreply@github.com>2022-12-19 22:59:54 +0000
commit989bd36eeb6dd6c4b391900765847cdcf87484d9 (patch)
tree86b15ce6804500b56f9f3c6b807d5fbb8aa6dad4 /src/webpack/patchWebpack.ts
parent4974c53f9cc3a3adccfa11f4af68ac4f190b0fc8 (diff)
downloadVencord-989bd36eeb6dd6c4b391900765847cdcf87484d9.tar.gz
Vencord-989bd36eeb6dd6c4b391900765847cdcf87484d9.tar.bz2
Vencord-989bd36eeb6dd6c4b391900765847cdcf87484d9.zip
refactor: identifier escapes + "self" group (#339)
Co-authored-by: Ven <vendicated@riseup.net>
Diffstat (limited to 'src/webpack/patchWebpack.ts')
-rw-r--r--src/webpack/patchWebpack.ts12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts
index 8f11b63..7b318b2 100644
--- a/src/webpack/patchWebpack.ts
+++ b/src/webpack/patchWebpack.ts
@@ -18,6 +18,8 @@
import { WEBPACK_CHUNK } from "@utils/constants";
import Logger from "@utils/Logger";
+import { canonicalizeReplacement } from "@utils/patches";
+import { PatchReplacement } from "@utils/types";
import { _initWebpack } from ".";
@@ -135,15 +137,17 @@ function patchPush() {
if (code.includes(patch.find)) {
patchedBy.add(patch.plugin);
- // @ts-ignore we change all patch.replacement to array in plugins/index
- for (const replacement of patch.replacement) {
+ // we change all patch.replacement to array in plugins/index
+ for (const replacement of patch.replacement as PatchReplacement[]) {
if (replacement.predicate && !replacement.predicate()) continue;
const lastMod = mod;
const lastCode = code;
+ canonicalizeReplacement(replacement, patch.plugin);
+
try {
- const newCode = code.replace(replacement.match, replacement.replace);
- if (newCode === code && !replacement.noWarn) {
+ const newCode = code.replace(replacement.match, replacement.replace as string);
+ if (newCode === code && !patch.noWarn) {
logger.warn(`Patch by ${patch.plugin} had no effect (Module id is ${id}): ${replacement.match}`);
if (IS_DEV) {
logger.debug("Function Source:\n", code);