I have configured my vite config as stated here https://web3auth.io/docs/troubleshooting/vite-issues
It runs the project at local server but during building for production it is giving me this error and I can't find solution
Error when using sourcemap for reporting an error: Can't resolve original location of error. ✓ 4 modules transformed. [commonjs--resolver] Unexpected token file: D:/Github devsalman247/Metadots/Speak'r/speakr/client/node_modules/rollup-plugin-node-polyfills/polyfills/buffer-es6.js:1:73 1: import { default as global } from 'D:/Github devsalman247/Metadots/Speak'r/speakr/client/node_modules/rollup-plugin-node-polyfills/polyfills/global.js'; ^ 2: 3: var lookup = []; error during build: Error: Unexpected token at error (file:///D:/Github%20devsalman247/Metadots/Speak'r/speakr/client/node_modules/rollup/dist/es/shared/rollup.js:1858:30) at Module.error (file:///D:/Github%20devsalman247/Metadots/Speak'r/speakr/client/node_modules/rollup/dist/es/shared/rollup.js:12429:16) at Module.tryParse (file:///D:/Github%20devsalman247/Metadots/Speak'r/speakr/client/node_modules/rollup/dist/es/shared/rollup.js:12806:25) at Module.setSource (file:///D:/Github%20devsalman247/Metadots/Speak'r/speakr/client/node_modules/rollup/dist/es/shared/rollup.js:12711:24) at ModuleLoader.addModuleSource (file:///D:/Github%20devsalman247/Metadots/Speak'r/speakr/client/node_modules/rollup/dist/es/shared/rollup.js:21959:20)
My ViteJS Config -->
export default defineConfig({
plugins: [react()],
server: {
port: 3000,
},
resolve: {
alias: {
// This Rollup aliases are extracted from @esbuild-plugins/node-modules-polyfill,
// see esbuild-plugins/polyfills.ts at master · remorses/esbuild-plugins · GitHub
util: "rollup-plugin-node-polyfills/polyfills/util",
sys: "util",
events: "rollup-plugin-node-polyfills/polyfills/events",
stream: "rollup-plugin-node-polyfills/polyfills/stream",
path: "rollup-plugin-node-polyfills/polyfills/path",
querystring: "rollup-plugin-node-polyfills/polyfills/qs",
punycode: "rollup-plugin-node-polyfills/polyfills/punycode",
url: "rollup-plugin-node-polyfills/polyfills/url",
http: "rollup-plugin-node-polyfills/polyfills/http",
https: "rollup-plugin-node-polyfills/polyfills/http",
os: "rollup-plugin-node-polyfills/polyfills/os",
assert: "rollup-plugin-node-polyfills/polyfills/assert",
constants: "rollup-plugin-node-polyfills/polyfills/constants",
_stream_duplex:
"rollup-plugin-node-polyfills/polyfills/readable-stream/duplex",
_stream_passthrough:
"rollup-plugin-node-polyfills/polyfills/readable-stream/passthrough",
_stream_readable:
"rollup-plugin-node-polyfills/polyfills/readable-stream/readable",
_stream_writable:
"rollup-plugin-node-polyfills/polyfills/readable-stream/writable",
_stream_transform:
"rollup-plugin-node-polyfills/polyfills/readable-stream/transform",
timers: "rollup-plugin-node-polyfills/polyfills/timers",
console: "rollup-plugin-node-polyfills/polyfills/console",
vm: "rollup-plugin-node-polyfills/polyfills/vm",
zlib: "rollup-plugin-node-polyfills/polyfills/zlib",
tty: "rollup-plugin-node-polyfills/polyfills/tty",
domain: "rollup-plugin-node-polyfills/polyfills/domain",
buffer: "rollup-plugin-node-polyfills/polyfills/buffer-es6",
process: "rollup-plugin-node-polyfills/polyfills/process-es6",
},
},
optimizeDeps: {
esbuildOptions: {
target: "es2020",
supported: { bigint: true },
plugins: [NodeModulesPolyfillPlugin()],
},
},
build: {
target: "es2020",
rollupOptions: {
plugins: [
// Enable rollup polyfills plugin
// used during production bundling
builtins(),
rollupNodePolyFill(),
],
},
},
});“>
import { defineConfig } from “vite”;
import react from ”@vitejs/plugin-react";
import { NodeModulesPolyfillPlugin } from “@esbuild-plugins/node-modules-polyfill”;
import rollupNodePolyFill from “rollup-plugin-node-polyfills”;
import builtins from “rollup-plugin-node-builtins”;// Configuring Vite | Vite
export default defineConfig({
plugins: [react()],
server: {
port: 3000,
},
resolve: {
alias: {
// This Rollup aliases are extracted from @esbuild-plugins/node-modules-polyfill,
// see esbuild-plugins/polyfills.ts at master · remorses/esbuild-plugins · GitHub
util: “rollup-plugin-node-polyfills/polyfills/util”,
sys: “util”,
events: “rollup-plugin-node-polyfills/polyfills/events”,
stream: “rollup-plugin-node-polyfills/polyfills/stream”,
path: “rollup-plugin-node-polyfills/polyfills/path”,
querystring: “rollup-plugin-node-polyfills/polyfills/qs”,
punycode: “rollup-plugin-node-polyfills/polyfills/punycode”,
url: “rollup-plugin-node-polyfills/polyfills/url”,
http: “rollup-plugin-node-polyfills/polyfills/http”,
https: “rollup-plugin-node-polyfills/polyfills/http”,
os: “rollup-plugin-node-polyfills/polyfills/os”,
assert: “rollup-plugin-node-polyfills/polyfills/assert”,
constants: “rollup-plugin-node-polyfills/polyfills/constants”,
_stream_duplex:
“rollup-plugin-node-polyfills/polyfills/readable-stream/duplex”,
_stream_passthrough:
“rollup-plugin-node-polyfills/polyfills/readable-stream/passthrough”,
_stream_readable:
“rollup-plugin-node-polyfills/polyfills/readable-stream/readable”,
_stream_writable:
“rollup-plugin-node-polyfills/polyfills/readable-stream/writable”,
_stream_transform:
“rollup-plugin-node-polyfills/polyfills/readable-stream/transform”,
timers: “rollup-plugin-node-polyfills/polyfills/timers”,
console: “rollup-plugin-node-polyfills/polyfills/console”,
vm: “rollup-plugin-node-polyfills/polyfills/vm”,
zlib: “rollup-plugin-node-polyfills/polyfills/zlib”,
tty: “rollup-plugin-node-polyfills/polyfills/tty”,
domain: “rollup-plugin-node-polyfills/polyfills/domain”,
buffer: “rollup-plugin-node-polyfills/polyfills/buffer-es6”,
process: “rollup-plugin-node-polyfills/polyfills/process-es6”,
},
},
optimizeDeps: {
esbuildOptions: {
target: “es2020”,
supported: { bigint: true },
plugins: [NodeModulesPolyfillPlugin()],
},
},
build: {
target: “es2020”,
rollupOptions: {
plugins: [
// Enable rollup polyfills plugin
// used during production bundling
builtins(),
rollupNodePolyFill(),
],
},
},
});
Originally posted by: devsalman247
Check the discussion at: https://github.com/orgs/Web3Auth/discussions/1261