diff --git a/src/components/settings/tabs/patchHelper/PatchPreview.tsx b/src/components/settings/tabs/patchHelper/PatchPreview.tsx index 46613f19a..66c58912b 100644 --- a/src/components/settings/tabs/patchHelper/PatchPreview.tsx +++ b/src/components/settings/tabs/patchHelper/PatchPreview.tsx @@ -11,8 +11,8 @@ import { ReplaceFn } from "@utils/types"; import { Button, Forms, Parser, useMemo, useState } from "@webpack/common"; import type { Change } from "diff"; -// Do not include diff in non dev builds (side effects import) -if (IS_DEV) { +// Do not include diff in standalone builds (side effects import) +if (!IS_STANDALONE) { var differ = require("diff") as typeof import("diff"); } @@ -128,7 +128,10 @@ export function PatchPreview({ module, match, replacement, setReplacementError } className={Margins.top20} onClick={() => { try { - Function(patchedCode.replace(/^(?=function\()/, "0,")); + const isArrowFunction = patchedCode.startsWith("("); + const wrappedCode = "0," + (!isArrowFunction ? "function" : "") + patchedCode.slice(patchedCode.indexOf("(")); + Function(wrappedCode.replace(/^(?=function\()/, "0,")); + setCompileResult([true, "Compiled successfully"]); } catch (err) { setCompileResult([false, (err as Error).message]); diff --git a/src/components/settings/tabs/patchHelper/index.tsx b/src/components/settings/tabs/patchHelper/index.tsx index bd99f5c8b..b23aeddd7 100644 --- a/src/components/settings/tabs/patchHelper/index.tsx +++ b/src/components/settings/tabs/patchHelper/index.tsx @@ -164,4 +164,4 @@ function PatchHelper() { ); } -export default IS_DEV ? wrapTab(PatchHelper, "PatchHelper") : null; +export default !IS_STANDALONE ? wrapTab(PatchHelper, "PatchHelper") : null; diff --git a/src/plugins/_core/settings.tsx b/src/plugins/_core/settings.tsx index e76f19c6e..31433e1bf 100644 --- a/src/plugins/_core/settings.tsx +++ b/src/plugins/_core/settings.tsx @@ -208,7 +208,7 @@ export default definePlugin({ Component: BackupAndRestoreTab, Icon: BackupRestoreIcon }), - IS_DEV && PatchHelperTab && buildEntry({ + !IS_STANDALONE && PatchHelperTab && buildEntry({ key: "vencord_patch_helper", title: "Patch Helper", Component: PatchHelperTab,