diff --git a/web/src/polyfills/buffer-shim.ts b/web/src/polyfills/buffer-shim.ts new file mode 100644 index 00000000..c34557b4 --- /dev/null +++ b/web/src/polyfills/buffer-shim.ts @@ -0,0 +1,4 @@ +// Buffer polyfill shim for vite-plugin-node-polyfills +import { Buffer } from 'buffer'; +export { Buffer }; +export default Buffer; diff --git a/web/src/polyfills/global-shim.ts b/web/src/polyfills/global-shim.ts new file mode 100644 index 00000000..b0564b59 --- /dev/null +++ b/web/src/polyfills/global-shim.ts @@ -0,0 +1,2 @@ +// Global polyfill shim for vite-plugin-node-polyfills +export default typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : {}; diff --git a/web/src/polyfills/process-shim.ts b/web/src/polyfills/process-shim.ts new file mode 100644 index 00000000..78fdfdb8 --- /dev/null +++ b/web/src/polyfills/process-shim.ts @@ -0,0 +1,9 @@ +// Process polyfill shim for vite-plugin-node-polyfills +const processShim = { + env: {}, + browser: true, + version: '', + versions: {}, +}; + +export default processShim; diff --git a/web/vite.config.ts b/web/vite.config.ts index da9f63a9..a81876e5 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -50,6 +50,10 @@ export default defineConfig(() => ({ "@local/types": path.resolve(__dirname, "../shared/types"), "@pezkuwi/components": path.resolve(__dirname, "../shared/components"), "@shared": path.resolve(__dirname, "../shared"), + // Node polyfill shims for shared folder (outside web workspace) + 'vite-plugin-node-polyfills/shims/buffer': path.resolve(__dirname, './src/polyfills/buffer-shim.ts'), + 'vite-plugin-node-polyfills/shims/global': path.resolve(__dirname, './src/polyfills/global-shim.ts'), + 'vite-plugin-node-polyfills/shims/process': path.resolve(__dirname, './src/polyfills/process-shim.ts'), }, dedupe: ['react', 'lucide-react', 'sonner', '@pezkuwi/util-crypto', '@pezkuwi/util', '@pezkuwi/api', '@pezkuwi/extension-dapp', '@pezkuwi/keyring'], },