From 40f4ebaa7d80a49a2c7db6b0cb7a17723d401067 Mon Sep 17 00:00:00 2001 From: Theo Ephraim Date: Tue, 9 Jan 2024 13:49:47 -0800 Subject: [PATCH] fix(web) shim node util for browserified version --- app/web/package.json | 1 + app/web/src/main.ts | 8 -------- app/web/vite.config.ts | 1 + pnpm-lock.yaml | 8 ++++++++ 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/web/package.json b/app/web/package.json index 87d443100a..032c1b3cd3 100644 --- a/app/web/package.json +++ b/app/web/package.json @@ -74,6 +74,7 @@ "reconnecting-websocket": "^4.4.0", "tinycolor2": "^1.4.2", "typescript": "^4.9.5", + "util-browser": "^0.0.2", "validator": "^13.7.0", "vanilla-picker": "^2.12.1", "vue": "^3.3.12", diff --git a/app/web/src/main.ts b/app/web/src/main.ts index 4e4e37fbc7..214b73a7a4 100644 --- a/app/web/src/main.ts +++ b/app/web/src/main.ts @@ -18,14 +18,6 @@ import store from "./store"; // this is for joi - because we are importing the source rather than the default build made for the browser globalThis.Buffer = Buffer; -// resolving an issue only seen on one user's machine... could not figure out why -// basically joi is using util - which references process.env... here we just creat it globablly so it wont explode -// and we'll at least fill in NODE_ENV becuase that's the most common thing that gets checked -if (typeof window !== "undefined") { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (window as any).process = { env: { NODE_ENV: import.meta.env.NODE_ENV } }; -} - const app = createApp(App); app.use(createHead()); diff --git a/app/web/vite.config.ts b/app/web/vite.config.ts index c66a2f2c44..3520cd3094 100644 --- a/app/web/vite.config.ts +++ b/app/web/vite.config.ts @@ -101,6 +101,7 @@ export default (opts: { mode: string }) => { find: "@", replacement: path.resolve(__dirname, "src"), }, + { find: "util", replacement: "util-browser" }, ], }, build: { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c080b61a78..92137d4103 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -245,6 +245,9 @@ importers: typescript: specifier: ^4.9.5 version: 4.9.5 + util-browser: + specifier: ^0.0.2 + version: 0.0.2 validator: specifier: ^13.7.0 version: 13.7.0 @@ -18376,6 +18379,11 @@ packages: engines: {node: '>=0.10.0'} dev: true + /util-browser@0.0.2: + resolution: {integrity: sha512-CsBJ5YROxA5mXq0TFFEk447bLcANx7O+MLhgJ8CCuZIOQaYUewpMeF0ODttYxOrWfCNny9b5l1nFMv4kd2MFdw==} + engines: {node: '>=0.10.x'} + dev: false + /util-deprecate@1.0.2: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} requiresBuild: true