File tree Expand file tree Collapse file tree 2 files changed +7
-10
lines changed Expand file tree Collapse file tree 2 files changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -15,18 +15,15 @@ class ForceGarbageCollectionPlugin {
15
15
compiler . hooks . done . tap ( this . constructor . name , ( ) => {
16
16
this . compilationCount ++ ;
17
17
18
- // Log memory usage every compilation
19
18
const memUsage = process . memoryUsage ( ) ;
20
19
const heapUsedMB = Math . round ( memUsage . heapUsed / 1024 / 1024 ) ;
21
20
const heapTotalMB = Math . round ( memUsage . heapTotal / 1024 / 1024 ) ;
22
21
23
22
console . log ( `📊 Compilation #${ this . compilationCount } - Heap: ${ heapUsedMB } MB/${ heapTotalMB } MB` ) ;
24
23
if ( this . compilationCount % 5 === 0 ) {
25
24
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 ?.( ) ;
28
26
29
- // Log memory after garbage collection
30
27
const memAfterGC = process . memoryUsage ( ) ;
31
28
const heapAfterMB = Math . round ( memAfterGC . heapUsed / 1024 / 1024 ) ;
32
29
console . log ( `✅ Post-GC heap size: ${ heapAfterMB } MB (freed ${ heapUsedMB - heapAfterMB } MB)` ) ;
Original file line number Diff line number Diff line change 4
4
# This script monitors for heap out of memory errors and automatically restarts
5
5
# Usage: ./start-dev-with-auto-restart.sh [webpack-dev-server arguments]
6
6
7
- WDS_ARGS=(" $@ " )
7
+ WEBPACK_DEV_SERVER_ARGS=(" $@ " )
8
+ readonly RESTART_DELAY=1
8
9
MAX_RESTARTS=10
9
10
RESTART_COUNT=0
10
- RESTART_DELAY=1
11
11
12
12
echo " 🚀 Starting webpack-dev-server with auto-restart (max restarts: $MAX_RESTARTS )"
13
13
14
14
run_wds () {
15
15
# 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
17
17
# 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
19
19
else
20
20
# 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
22
22
fi
23
23
}
24
24
25
- while [ $RESTART_COUNT -lt $MAX_RESTARTS ]; do
25
+ while [[ $RESTART_COUNT -lt $MAX_RESTARTS ] ]; do
26
26
echo " 📊 Attempt #$(( RESTART_COUNT + 1 )) - Starting webpack-dev-server..."
27
27
28
28
if [ $RESTART_COUNT -eq 0 ]; then
You can’t perform that action at this time.
0 commit comments