Node polyfills

Hi, little optimization question: One of the libraries I use requires Node polyfilling, so I currently do the following in my nuxtConfig:
vite: {
plugins: [
nodePolyfills({
include: ["buffer", "process"],
globals: {
Buffer: true,
global: true,
process: true,
},
protocolImports: false,
}),
],
},
vite: {
plugins: [
nodePolyfills({
include: ["buffer", "process"],
globals: {
Buffer: true,
global: true,
process: true,
},
protocolImports: false,
}),
],
},
Given that Nuxt v3.10 provides client-side Node.js support, can I use
import { Buffer } from 'node:buffer'
import process from 'node:process'

globalThis.Buffer = Buffer
globalThis.process = process
import { Buffer } from 'node:buffer'
import process from 'node:process'

globalThis.Buffer = Buffer
globalThis.process = process
somehow and avoid using the vite node polyfills library? Would it make a difference? Also, in case it helps, the library that needs the Node built ins is isolated in a client-only plugin. It provides a helper class that is used throughout some parts of the app. The library is @web3auth/single-factor-auth in case anyone has experience with it too. I would love to just use their node sdk on the backend but can't due to business and compliance reasons. Any insight or tips would be appreciated!
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server