Skip to content

Commit cf1b8aa

Browse files
sjdthreeclaude
andcommitted
optimize: fix JS heap memory errors and reduce bundle size
**Memory Fixes:** - Increased Node.js heap size to 8GB for Netlify builds - Added NODE_OPTIONS='--max-old-space-size=8192' to build command **Dependency Optimization:** - Pinned all "latest" dependencies to specific versions to prevent conflicts - Fixed 6 duplicate versions of 'ox' library causing massive bloat - @dynamic-labs/ethereum: latest -> 4.32.0 - viem: latest -> 2.37.6 - wagmi: latest -> 2.17.0 **Bundle Splitting:** - Added manual chunk splitting in Vite config: - vendor.js (141KB) - React core - wallet.js (4.4MB) - Wallet/crypto libs - ui.js (259KB) - MUI components - main.js (1MB) - App code - Reduced main bundle from 5.8MB to 1MB **Build Performance:** - Maintained 22s build time locally - Should prevent "heap out of memory" errors on Netlify 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent bc92e44 commit cf1b8aa

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

frontend/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6-
"@dynamic-labs/ethereum": "latest",
7-
"@dynamic-labs/sdk-react-core": "latest",
8-
"@dynamic-labs/wagmi-connector": "latest",
6+
"@dynamic-labs/ethereum": "4.32.0",
7+
"@dynamic-labs/sdk-react-core": "3.9.2",
8+
"@dynamic-labs/wagmi-connector": "3.9.2",
99
"@emotion/react": "^11.13.3",
1010
"@emotion/styled": "^11.13.0",
1111
"@fortawesome/fontawesome-svg-core": "^6.6.0",
@@ -36,11 +36,11 @@
3636
"stream-http": "^3.2.0",
3737
"url": "^0.11.4",
3838
"util": "^0.12.5",
39-
"viem": "latest",
39+
"viem": "2.37.6",
4040
"vite": "^5.4.6",
4141
"vite-plugin-node-polyfills": "^0.21.0",
4242
"vite-plugin-pwa": "^0.20.5",
43-
"wagmi": "latest",
43+
"wagmi": "2.17.0",
4444
"web3": "^4.12.1"
4545
},
4646
"scripts": {

frontend/vite.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,15 @@ export default defineConfig({
8989
sourcemap: true,
9090
commonjsOptions: {
9191
transformMixedEsModules: true,
92+
},
93+
rollupOptions: {
94+
output: {
95+
manualChunks: {
96+
vendor: ['react', 'react-dom'],
97+
wallet: ['@dynamic-labs/ethereum', '@dynamic-labs/sdk-react-core', 'viem', 'wagmi'],
98+
ui: ['@mui/material', '@mui/icons-material', '@emotion/react', '@emotion/styled']
99+
}
100+
}
92101
}
93102
}
94103
});

netlify.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
[build]
22
publish = "frontend/dist"
3-
command = "cd frontend && npm ci --include=optional && (npm install -D --no-save --package-lock=false @rollup/rollup-linux-x64-gnu || true) && npm run build"
3+
command = "cd frontend && npm ci --include=optional && (npm install -D --no-save --package-lock=false @rollup/rollup-linux-x64-gnu || true) && NODE_OPTIONS='--max-old-space-size=8192' npm run build"
44
base = "."
55

66
[build.environment]
77
NODE_VERSION = "20"
88
NPM_FLAGS = "--production=false"
9+
NODE_OPTIONS = "--max-old-space-size=8192"
910

1011
[[redirects]]
1112
from = "/*"

0 commit comments

Comments
 (0)