Faced some polyfill issue with v0.14.1 but v0.14.0 too. It seems I solved it that way:
- installer buffer for the browser
npm i buffer
- polyfill esbuild
npm i @esbuild-plugins/node-modules-polyfill @esbuild-plugins/node-globals-polyfill @rollup/plugin-inject -D
in vite.config
build: {
target: 'es2020',
rollupOptions: {
// Polyfill Buffer for production build
plugins: [
inject({
modules: { Buffer: ['buffer', 'Buffer'] }
})
]
}
},
optimizeDeps: {
esbuildOptions: {
// Node.js global to browser globalThis
define: {
global: 'globalThis'
},
// Enable esbuild polyfill plugins
plugins: [NodeGlobalsPolyfillPlugin(), NodeModulesPolyfillPlugin()]
}
}