diff --git a/build.mjs b/build.mjs index 38f92ca..6ee549c 100644 --- a/build.mjs +++ b/build.mjs @@ -1,5 +1,6 @@ import { build } from "esbuild"; import alias from "esbuild-plugin-alias"; +import esg from "esbuild-plugin-external-global"; import fs from "fs/promises"; import path from "path"; @@ -13,9 +14,13 @@ try { minify: true, bundle: true, format: "iife", - external: ["react", "react-native"], target: "esnext", - plugins: [alias(aliases)], + plugins: [ + alias(aliases), + esg.externalGlobalPlugin({ + "react": "window.React", + }) + ], legalComments: "external", }); diff --git a/package.json b/package.json index cf5590c..6199fe2 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "@types/react-native": "^0.70.5", "esbuild": "^0.15.11", "esbuild-plugin-alias": "^0.2.1", + "esbuild-plugin-external-global": "^1.0.1", "redux": "^4.2.0", "typescript": "^4.8.4", "zustand": "^4.1.2" diff --git a/src/index.ts b/src/index.ts index d8c4a1c..7461c97 100644 --- a/src/index.ts +++ b/src/index.ts @@ -19,10 +19,6 @@ async function init() { let erroredOnLoad = false; try { - initSettings(); - patchAssets(); - patchLogHook(); - window.vendetta = { patcher: patcher, metro: { ...metro, common: { ...common } }, @@ -48,6 +44,10 @@ async function init() { }, logger: logger, }; + + initSettings(); + patchAssets(); + patchLogHook(); } catch (e: Error | any) { erroredOnLoad = true; alert(`Vendetta failed to initialize...\n${e.stack || e.toString()}`);