@@ -107,9 +107,9 @@ public static class Builder implements Supplier<JavaScriptRewriteRpc> {
107107 private Duration timeout = Duration .ofSeconds (30 );
108108 private boolean traceRpcMessages ;
109109 private @ Nullable Integer inspectBrk ;
110- private boolean profiler ;
111110 private @ Nullable Integer maxHeapSize ;
112111 private @ Nullable Path workingDirectory ;
112+ private ClassLoader recipeClassLoader = JavaScriptRewriteRpc .class .getClassLoader ();
113113
114114 public Builder marketplace (Environment marketplace ) {
115115 this .marketplace = marketplace ;
@@ -181,26 +181,6 @@ public Builder inspectBrk() {
181181 return inspectBrk (9229 );
182182 }
183183
184- /**
185- * Enable V8 CPU profiling for performance analysis. When enabled, the process will
186- * generate a CPU profile that can be analyzed to identify performance bottlenecks.
187- * The profile is saved in Chrome DevTools format (.cpuprofile) on shutdown.
188- * <p>
189- * Profiling uses the V8 Inspector API and works with both npx and direct node execution modes.
190- * The profile file can be loaded in Chrome DevTools for analysis.
191- *
192- * @param profiler Whether to enable profiling
193- * @return This builder
194- */
195- public Builder profiler (boolean profiler ) {
196- this .profiler = profiler ;
197- return this ;
198- }
199-
200- public Builder profiler () {
201- return profiler (true );
202- }
203-
204184 /**
205185 * Set the maximum heap size for the Node.js process in megabytes.
206186 * Default V8 heap size is approximately 1.5-2 GB on 64-bit systems.
@@ -227,6 +207,11 @@ public Builder workingDirectory(@Nullable Path workingDirectory) {
227207 return this ;
228208 }
229209
210+ public Builder recipeClassLoader (ClassLoader recipeClassLoader ) {
211+ this .recipeClassLoader = recipeClassLoader ;
212+ return this ;
213+ }
214+
230215 @ Override
231216 public JavaScriptRewriteRpc get () {
232217 Stream <@ Nullable String > cmd ;
@@ -245,7 +230,6 @@ public JavaScriptRewriteRpc get() {
245230 "node" ,
246231 "--enable-source-maps" ,
247232 "--inspect-brk=" + inspectBrk ,
248- profiler ? "--prof" : null ,
249233 maxHeapSize != null ? "--max-old-space-size=" + maxHeapSize : null ,
250234 serverJs .toAbsolutePath ().normalize ().toString (),
251235 log == null ? null : "--log-file=" + log .toAbsolutePath ().normalize (),
@@ -262,8 +246,7 @@ public JavaScriptRewriteRpc get() {
262246 log == null ? null : "--log-file=" + log .toAbsolutePath ().normalize (),
263247 metricsCsv == null ? null : "--metrics-csv=" + metricsCsv .toAbsolutePath ().normalize (),
264248 traceRpcMessages ? "--trace-rpc-messages" : null ,
265- recipeInstallDir == null ? null : "--recipe-install-dir=" + recipeInstallDir .toAbsolutePath ().normalize (),
266- profiler ? "--profile" : null
249+ recipeInstallDir == null ? null : "--recipe-install-dir=" + recipeInstallDir .toAbsolutePath ().normalize ()
267250 );
268251 }
269252
@@ -293,7 +276,8 @@ public JavaScriptRewriteRpc get() {
293276 String .join (" " , cmdArr ), process .environment ())
294277 .livenessCheck (process ::getLivenessCheck )
295278 .timeout (timeout )
296- .log (log == null ? null : new PrintStream (Files .newOutputStream (log , StandardOpenOption .APPEND , StandardOpenOption .CREATE )));
279+ .log (log == null ? null : new PrintStream (Files .newOutputStream (log , StandardOpenOption .APPEND , StandardOpenOption .CREATE )))
280+ .recipeClassLoader (recipeClassLoader );
297281 } catch (IOException e ) {
298282 throw new UncheckedIOException (e );
299283 }
0 commit comments