Vite+Pollyfill+crx conflicts

When asking for help in this category, please make sure to provide the following details:

  • SDK Version(package.json):
    “crxjs/vite-plugin”: “1.0.13”,
    “web3auth/base”: “^8.0.0”,
    “web3auth/ethereum-provider”: “^8.0.1”,
    “web3auth/no-modal”: “^8.0.1”,
    “web3auth/openlogin-adapter”: “^8.0.1”,
    “vite”: “^2.9.17”,
    “vite-plugin-node-polyfills”: “0.21.0”

  • Cause:
    When installed vite+globalpolyfill + crx to create a Google Chrome plug-in,we found
    "Duplicate injected file “node_modules/@esbuild-plugins/node-globals-polyfill/virtual-process-polyfill.js” &
    “Duplicate injected file “node_modules/@esbuild-plugins/node-globals-polyfill/_buffer.js””
    as below:

  • Repo:
    the git repo is :GitHub - zhbyak/vite-globalpolyfill-crx-example
    Just use yarn & yarn dev to make the bug come back.

hi @pingqian1991,

your issue has been forwarded to our Dev team and we will get back with further updates.

1 Like

Hey @pingqian1991,

Welcome aboard. I see you’re facing and issue revolving around duplicate polyfills.
The issue with duplicate injected files is likely due to using both vite-plugin-node-polyfills and @esbuild-plugins/node-globals-polyfill in your project. To fix this:

  1. Choose One Polyfill Plugin: Determine which plugin fits your needs best and remove the other from your vite.config.js.
  2. Adjust Your Configuration: Update your vite.config.js to correctly configure the chosen plugin.
  3. Test Your Build: Run yarn dev to ensure the issue is resolved and your plugin works as expected.

This should help eliminate the duplicate injection errors. If you’re still facing issues, please check the plugin documentation for any specific configurations needed.