Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Vite build error #2228

Closed
1 task done
RexHung0302 opened this issue Apr 25, 2023 · 3 comments
Closed
1 task done

bug: Vite build error #2228

RexHung0302 opened this issue Apr 25, 2023 · 3 comments
Labels
Needs Reproduction Misc: Needs Reproduction

Comments

@RexHung0302
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Package Version

0.4.9

Current Behavior

I'm use wagmi on my project, here is my project basic setting:

  • "vite": "^2.9.9"
  • "react": "^18.0.0"
  • "wagmi": "^0.5.9"

I got error like 'EventEmitter' is not exported by __vite-browser-external, imported by node_modules/@walletconnect/jsonrpc-provider/dist/esm/provider.js file: xxxx/xxxx/xxxx/xxxx, I don't use walletconnect on my project, so I think this is wagmi dependency, why I got this error?

截圖 2023-04-25 下午2 28 28

Expected Behavior

I expected build success.

Steps To Reproduce

  1. yarn install
  2. yarn build
  3. got error

Link to Minimal Reproducible Example (StackBlitz, CodeSandbox, GitHub repo etc.)

No response

Anything else?

No response

@jxom
Copy link
Member

jxom commented Apr 25, 2023

Thanks for reporting. This issue is temporarily closed due to lack of information. Please provide a minimal reproducible example via a https://new.wagmi.sh fork and I'll reopen this issue.

https://new.wagmi.sh is a Vite project that successfully compiles a wagmi application. Might be worth cross-referencing your app with that one.

@jxom jxom closed this as not planned Won't fix, can't repro, duplicate, stale Apr 25, 2023
@jxom jxom added the Needs Reproduction Misc: Needs Reproduction label Apr 25, 2023
@RexHung0302
Copy link
Author

RexHung0302 commented Apr 25, 2023

Sorry, I found the problem.

vitejs/vite#7821

I don't use any EventEmitter on my project, so I search dose anyone happended this problem too.

I install vite-plugin-node-polyfills for my vite project, and add nodePolyfills setting on vite.config.ts then resolve this problem.

import { defineConfig } from 'vite';
import { resolve } from 'path';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
import react from '@vitejs/plugin-react';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    react(),
    // I add this on my project
    nodePolyfills({
      protocolImports: true,
    }),
  ],
  // server: {
  //   host: '0.0.0.0',
  // },
  base: '/',
  esbuild: {
    drop: process.env.NODE_ENV === 'production' ? ['console', 'debugger'] : [],
  },
  resolve: {
    alias: [
      {
        find: '@',
        replacement: resolve(__dirname, 'src'),
      },
      {
        find: '@utils',
        replacement: resolve(__dirname, 'src/utils'),
      },
      {
        find: '@constants',
        replacement: resolve(__dirname, 'src/constants'),
      },
      {
        find: '@store',
        replacement: resolve(__dirname, 'src/store'),
      },
      {
        find: '@components',
        replacement: resolve(__dirname, 'src/components'),
      },
      {
        find: '@assets',
        replacement: resolve(__dirname, 'src/assets'),
      },
    ],
  },
});

I don't know why always build failed on jenkins, but sometime build success on local.
Hope this can help someone got this promble.

Copy link
Contributor

This issue has been locked since it has been closed for more than 14 days.

If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest wagmi version. If you have any other comments you can create a new discussion.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs Reproduction Misc: Needs Reproduction
Projects
None yet
Development

No branches or pull requests

2 participants