@@ -212,7 +212,6 @@ public static class Builder implements Supplier<JavaScriptRewriteRpc> {
212212 private @ Nullable Integer inspectBrk ;
213213 private @ Nullable Path inspectBrkRewriteSourcePath ;
214214
215- private @ Nullable Integer maxHeapSize ;
216215 private @ Nullable Path workingDirectory ;
217216
218217 public Builder marketplace (RecipeMarketplace marketplace ) {
@@ -301,19 +300,6 @@ public Builder inspectBrk(Path rewriteDistPath) {
301300 return inspectBrk (rewriteDistPath , 9229 );
302301 }
303302
304- /**
305- * Set the maximum heap size for the Node.js process in megabytes.
306- * Default V8 heap size is approximately 1.5-2 GB on 64-bit systems.
307- * For large repositories with many source files, you may need to increase this.
308- *
309- * @param maxHeapSize Maximum heap size in megabytes (e.g., 4096 for 4GB)
310- * @return This builder
311- */
312- public Builder maxHeapSize (@ Nullable Integer maxHeapSize ) {
313- this .maxHeapSize = maxHeapSize ;
314- return this ;
315- }
316-
317303 /**
318304 * Set the working directory for the Node.js process.
319305 * This affects where profile logs and other output files are generated.
@@ -341,7 +327,6 @@ public JavaScriptRewriteRpc get() {
341327 "node" ,
342328 "--enable-source-maps" ,
343329 "--inspect-brk=" + inspectBrk ,
344- maxHeapSize != null ? "--max-old-space-size=" + maxHeapSize : null ,
345330 serverJs .toAbsolutePath ().normalize ().toString (),
346331 log == null ? null : "--log-file=" + log .toAbsolutePath ().normalize (),
347332 traceRpcMessages ? "--trace-rpc-messages" : null ,
@@ -369,18 +354,9 @@ public JavaScriptRewriteRpc get() {
369354 process .setWorkingDirectory (workingDirectory );
370355 }
371356
372- // Build NODE_OPTIONS with all necessary flags
373- StringBuilder nodeOptions = new StringBuilder ("--enable-source-maps" );
374- if (inspectBrk == null ) {
375- // When not using inspect-brk, we need to pass Node.js flags via NODE_OPTIONS
376- // since npx spawns a child process
377- // Note: --prof is not allowed in NODE_OPTIONS for security reasons
378- if (maxHeapSize != null ) {
379- nodeOptions .append (" --max-old-space-size=" ).append (maxHeapSize );
380- }
381- }
382357 process .environment ().putAll (environment );
383- process .environment ().put ("NODE_OPTIONS" , nodeOptions .toString ());
358+ // caller-provided options, if any, are taking precedence over the options baked above
359+ process .environment ().merge ("NODE_OPTIONS" , " --enable-source-maps" , (callerProvided , local ) -> local + " " + callerProvided );
384360 if (npxPath .getParent () != null ) {
385361 // `npx` is typically a shebang script alongside the `node` executable
386362 process .environment ().put ("PATH" , npxPath .getParent () + File .pathSeparator +
0 commit comments