File tree 1 file changed +11
-8
lines changed 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -282,20 +282,23 @@ func main() {
282
282
exitCode = cli .Run (osArgs )
283
283
}
284
284
} else {
285
- // Don't disable the GC if this is a long-running process
286
285
isServeOrWatch := false
286
+ nonFlagCount := 0
287
287
for _ , arg := range osArgs {
288
- if arg == "--serve" || arg == "--watch" || strings .HasPrefix (arg , "--serve=" ) {
288
+ if ! strings .HasPrefix (arg , "-" ) {
289
+ nonFlagCount ++
290
+ } else if arg == "--serve" || arg == "--watch" || strings .HasPrefix (arg , "--serve=" ) {
289
291
isServeOrWatch = true
290
- break
291
292
}
292
293
}
293
294
294
- if ! isServeOrWatch {
295
- // Disable the GC since we're just going to allocate a bunch of memory
296
- // and then exit anyway. This speedup is not insignificant. Make sure to
297
- // only do this here once we know that we're not going to be a long-lived
298
- // process though.
295
+ if ! isServeOrWatch && nonFlagCount <= 1 {
296
+ // If this is not a long-running process and there is at most a single
297
+ // entry point, then disable the GC since we're just going to allocate
298
+ // a bunch of memory and then exit anyway. This speedup is not
299
+ // insignificant. We don't do this when there are multiple entry points
300
+ // since otherwise esbuild could unnecessarily use much more memory
301
+ // than it might otherwise need to process many entry points.
299
302
debug .SetGCPercent (- 1 )
300
303
} else if ! isStdinTTY && ! isWatchForever {
301
304
// If stdin isn't a TTY, watch stdin and abort in case it is closed.
You can’t perform that action at this time.
0 commit comments