Skip to content

Commit d24934d

Browse files
committed
fix: Buffer is not defined
1 parent 59ac69e commit d24934d

File tree

3 files changed

+801
-4571
lines changed

3 files changed

+801
-4571
lines changed

examples/vite-react/package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
"@emotion/styled": "^11.11.0",
1717
"@hookform/resolvers": "^3.3.4",
1818
"@tanstack/react-query": "5.68.0",
19+
"buffer": "^6.0.3",
1920
"framer-motion": "^11.0.8",
2021
"react": "^18.3.1",
2122
"react-dom": "^18.3.1",
2223
"react-hook-form": "^7.51.0",
2324
"zod": "^3.22.4"
2425
},
2526
"devDependencies": {
27+
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
2628
"@eslint/js": "^9.9.1",
2729
"@types/react": "^18.3.5",
2830
"@types/react-dom": "^18.3.0",
@@ -35,4 +37,4 @@
3537
"typescript-eslint": "^8.3.0",
3638
"vite": "^5.4.2"
3739
}
38-
}
40+
}

examples/vite-react/vite.config.ts

+18
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
11
import { defineConfig } from 'vite'
22
import react from '@vitejs/plugin-react'
3+
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill';
34

45
// https://vitejs.dev/config/
56
export default defineConfig({
67
plugins: [react()],
8+
optimizeDeps: {
9+
esbuildOptions: {
10+
define: {
11+
global: 'globalThis'
12+
},
13+
plugins: [
14+
NodeGlobalsPolyfillPlugin({
15+
buffer: true,
16+
})
17+
]
18+
}
19+
},
20+
resolve: {
21+
alias: {
22+
buffer: 'buffer'
23+
}
24+
}
725
})

0 commit comments

Comments
 (0)