Closed ocluf closed 1 week ago
Currently the sveltekit example uses the inject plugin to add the Buffer module in vite.config.ts.
vite.config.ts
build: { target: "esnext", rollupOptions: { // Polyfill Buffer for production build plugins: [ inject({ modules: { Buffer: ["buffer", "Buffer"] }, }), ], }, },
This makes sure important packages work when building a project, but not when the project is in dev mode. I got it working there by adding
import { NodeGlobalsPolyfillPlugin } from "@esbuild-plugins/node-globals-polyfill"; import { NodeModulesPolyfillPlugin } from "@esbuild-plugins/node-modules-polyfill"; // rest of the config optimizeDeps: { esbuildOptions: { // Node.js global to browser globalThis define: { global: "globalThis", }, plugins: [ NodeModulesPolyfillPlugin(), //added this NodeGlobalsPolyfillPlugin({ buffer: true, }), ], }, },
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
Currently the sveltekit example uses the inject plugin to add the Buffer module in
vite.config.ts
.This makes sure important packages work when building a project, but not when the project is in dev mode. I got it working there by adding