File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,18 +15,15 @@ class ForceGarbageCollectionPlugin {
1515 compiler . hooks . done . tap ( this . constructor . name , ( ) => {
1616 this . compilationCount ++ ;
1717
18- // Log memory usage every compilation
1918 const memUsage = process . memoryUsage ( ) ;
2019 const heapUsedMB = Math . round ( memUsage . heapUsed / 1024 / 1024 ) ;
2120 const heapTotalMB = Math . round ( memUsage . heapTotal / 1024 / 1024 ) ;
2221
2322 console . log ( `📊 Compilation #${ this . compilationCount } - Heap: ${ heapUsedMB } MB/${ heapTotalMB } MB` ) ;
2423 if ( this . compilationCount % 5 === 0 ) {
2524 console . log ( `🗑️ Forcing garbage collection after ${ this . compilationCount } compilations` ) ;
26- // @ts -expect-error - gc is a global function provided when Node.js is started with --expose-gc flag
27- gc ( ) ;
25+ gc ?.( ) ;
2826
29- // Log memory after garbage collection
3027 const memAfterGC = process . memoryUsage ( ) ;
3128 const heapAfterMB = Math . round ( memAfterGC . heapUsed / 1024 / 1024 ) ;
3229 console . log ( `✅ Post-GC heap size: ${ heapAfterMB } MB (freed ${ heapUsedMB - heapAfterMB } MB)` ) ;
Original file line number Diff line number Diff line change 44# This script monitors for heap out of memory errors and automatically restarts
55# Usage: ./start-dev-with-auto-restart.sh [webpack-dev-server arguments]
66
7- WDS_ARGS=(" $@ " )
7+ WEBPACK_DEV_SERVER_ARGS=(" $@ " )
8+ readonly RESTART_DELAY=1
89MAX_RESTARTS=10
910RESTART_COUNT=0
10- RESTART_DELAY=1
1111
1212echo " 🚀 Starting webpack-dev-server with auto-restart (max restarts: $MAX_RESTARTS )"
1313
1414run_wds () {
1515 # Check if platform is Desktop to determine open behavior
16- if [[ " ${WDS_ARGS [*]} " == * " --env platform=desktop" * ]]; then
16+ if [[ " ${WEBPACK_DEV_SERVER_ARGS [*]} " == * " --env platform=desktop" * ]]; then
1717 # For Desktop, always use --no-open since app is handled by Electron
18- node --expose-gc --max-old-space-size=1100 ./node_modules/.bin/webpack-dev-server --no-open " ${WDS_ARGS [@]} " --config config/webpack/webpack.dev.ts
18+ node --expose-gc ./node_modules/.bin/webpack-dev-server --no-open " ${WEBPACK_DEV_SERVER_ARGS [@]} " --config config/webpack/webpack.dev.ts
1919 else
2020 # For Web, use the provided open flag
21- node --expose-gc ./node_modules/.bin/webpack-dev-server " $1 " " ${WDS_ARGS [@]} " --config config/webpack/webpack.dev.ts
21+ node --expose-gc ./node_modules/.bin/webpack-dev-server " $1 " " ${WEBPACK_DEV_SERVER_ARGS [@]} " --config config/webpack/webpack.dev.ts
2222 fi
2323}
2424
25- while [ $RESTART_COUNT -lt $MAX_RESTARTS ]; do
25+ while [[ $RESTART_COUNT -lt $MAX_RESTARTS ] ]; do
2626 echo " 📊 Attempt #$(( RESTART_COUNT + 1 )) - Starting webpack-dev-server..."
2727
2828 if [ $RESTART_COUNT -eq 0 ]; then
You can’t perform that action at this time.
0 commit comments