diff --git a/web/src/polyfills/crypto-shim.ts b/web/src/polyfills/crypto-shim.ts deleted file mode 100644 index 6b7a4b7c..00000000 --- a/web/src/polyfills/crypto-shim.ts +++ /dev/null @@ -1,11 +0,0 @@ -// Minimal crypto shim that delegates to the browser's native Web Crypto API -// Prevents crypto-browserify (and its inherits dependency) from being bundled -export default globalThis.crypto; -export const webcrypto = globalThis.crypto; -export const randomBytes = (size: number): Uint8Array => { - const bytes = new Uint8Array(size); - globalThis.crypto.getRandomValues(bytes); - return bytes; -}; -export const createHash = undefined; -export const createHmac = undefined; diff --git a/web/vite.config.ts b/web/vite.config.ts index 0c04a372..49db7790 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -61,7 +61,7 @@ export default defineConfig(() => ({ }, ].filter(Boolean), resolve: { - mainFields: ['module', 'main', 'exports'], + mainFields: ['browser', 'module', 'main', 'exports'], alias: { "@": path.resolve(__dirname, "./src"), "@pezkuwi/i18n": path.resolve(__dirname, "../shared/i18n"), @@ -75,8 +75,6 @@ export default defineConfig(() => ({ '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'), - // Prevent crypto-browserify chain (inherits error) - use native Web Crypto API - 'crypto-browserify': path.resolve(__dirname, './src/polyfills/crypto-shim.ts'), }, dedupe: ['react', 'lucide-react', 'sonner', '@pezkuwi/util-crypto', '@pezkuwi/util', '@pezkuwi/api', '@pezkuwi/extension-dapp', '@pezkuwi/keyring'], },