Web3Auth / web3auth-web

Simple infrastructure that enables Web3 wallets and applications to provide seamless user logins for both mainstream and Web3.0 users.
https://web3auth.io/docs
Other
426 stars 229 forks source link

Critical Production Build Error: Buffer is not defined - unable to use the page #933

Closed reemardelarosa closed 1 year ago

reemardelarosa commented 1 year ago

Describe the bug

Buffer is not defined when deployed to production but working in local development. Applied most of the solutions here but had no luck. https://github.com/vitejs/vite/discussions/2785

To Reproduce

Steps to reproduce the behavior:

  1. Go to https://wallet.dloyal.com/
  2. Open the devtools
  3. See the Buffer is not defined error.
  4. Signin page is not loading and the page is not usable. image

Replicated also in stackblitz setup https://stackblitz.com/edit/qwik-starter-dtpczo?file=adaptors/express/vite.config.ts

  1. Wait for the webcontainer to load and dependencies to be installed.
  2. run yarn serve
  3. Open console and see the Buffer error Screenshot 2022-11-25 at 11 09 02 AM

Expected behavior

web3core should load and the signing form will display.

In the local build, it is working.

Screenshot 2022-11-25 at 11 13 12 AM

https://user-images.githubusercontent.com/4918140/203891353-35f17394-33b5-4db1-a209-d6225701816d.mov

Screenshots

image

Device Info (please complete the following information):

Additional context

For reference

vite.config.ts

import nodePolyfills from 'rollup-plugin-node-polyfills';
import { expressAdaptor } from '@builder.io/qwik-city/adaptors/express/vite';
import { extendConfig } from '@builder.io/qwik-city/vite';
import baseConfig from '../../vite.config';

export default extendConfig(baseConfig, () => {
  return {
    build: {
      ssr: true,
      rollupOptions: {
        input: ['src/entry.express.tsx', '@qwik-city-plan'],
        plugins: [
          // Enable rollup polyfills plugin
          // used during production bundling
          nodePolyfills()
        ]
      },
    },
    plugins: [
      expressAdaptor({
        staticGenerate: true,
      }),
    ],
  };
});
chaitanyapotti commented 1 year ago

Pls follow the instructions here You can also reference our examples for sample apps