From f6ae01866d68a937bb19109e1c77268048ee8b71 Mon Sep 17 00:00:00 2001 From: "Tommy D. Rossi" Date: Thu, 1 Jan 2026 02:23:16 +0100 Subject: [PATCH] use ts relay in dev --- playwriter/src/mcp.ts | 9 +++++++-- playwriter/vitest.config.ts | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/playwriter/src/mcp.ts b/playwriter/src/mcp.ts index f5efa04..3ff8e00 100644 --- a/playwriter/src/mcp.ts +++ b/playwriter/src/mcp.ts @@ -20,6 +20,8 @@ import { Debugger } from './debugger.js' import { Editor } from './editor.js' import { getStylesForLocator, formatStylesAsText, type StylesResult } from './styles.js' import { getReactSource, type ReactSourceLocation } from './react-source.js' +const __filename = fileURLToPath(import.meta.url) +const __dirname = path.dirname(__filename) class CodeExecutionTimeoutError extends Error { constructor(timeout: number) { @@ -261,9 +263,12 @@ async function ensureRelayServer(): Promise { mcpLog('CDP relay server not running, starting it...') } - const scriptPath = require.resolve('../dist/start-relay-server.js') + const dev = process.env.PLAYWRITER_NODE_ENV === 'development' + const scriptPath = dev + ? path.resolve(__dirname, '../src/start-relay-server.ts') + : require.resolve('../dist/start-relay-server.js') - const serverProcess = spawn(process.execPath, [scriptPath], { + const serverProcess = spawn(dev ? 'tsx' : process.execPath, [scriptPath], { detached: true, stdio: 'ignore', env: { diff --git a/playwriter/vitest.config.ts b/playwriter/vitest.config.ts index 2f0989a..3cc4361 100644 --- a/playwriter/vitest.config.ts +++ b/playwriter/vitest.config.ts @@ -8,5 +8,8 @@ export default defineConfig({ hookTimeout: 30000, exclude: ['dist', 'dist/**/*', 'node_modules/**'], + env: { + PLAYWRITER_NODE_ENV: 'development', + }, }, })