From 5faed9cd888b4d57cc016e9125519781b99a4367 Mon Sep 17 00:00:00 2001 From: Jackie Macharia Date: Wed, 18 May 2022 10:49:01 +0300 Subject: [PATCH 1/3] feat: add deno --inspect and --inspect-brk flags --- src/server/server.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/server/server.ts b/src/server/server.ts index 45e5f454..ceeb51a6 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -75,6 +75,8 @@ interface ServeOptions { certificatePath?: string debug?: boolean distImportMapPath?: string + edgeInspect?: boolean | string + edgeInspectBrk?: boolean | string importMaps?: ImportMapFile[] onAfterDownload?: LifecycleHook onBeforeDownload?: LifecycleHook @@ -83,10 +85,13 @@ interface ServeOptions { port: number } +// eslint-disable-next-line complexity, max-statements const serve = async ({ certificatePath, debug, distImportMapPath, + edgeInspect, + edgeInspectBrk, formatExportTypeError, formatImportError, importMaps, @@ -122,6 +127,14 @@ const serve = async ({ flags.push('--quiet') } + if (edgeInspect) { + flags.push(typeof edgeInspect === 'boolean' ? '--inspect' : `--inspect${edgeInspect}`) + } + + if (edgeInspectBrk) { + flags.push(typeof edgeInspectBrk === 'boolean' ? '--inspect-brk' : `--inspect-brk${edgeInspectBrk}`) + } + const server = await prepareServer({ deno, distDirectory, From 8121f4762da08e5326f9e83bfe2958c40ca84f31 Mon Sep 17 00:00:00 2001 From: Jackie Macharia Date: Thu, 19 May 2022 14:17:18 +0300 Subject: [PATCH 2/3] chore: use single inspectSettings object --- src/server/server.ts | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/server/server.ts b/src/server/server.ts index ceeb51a6..22e27bd1 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -71,12 +71,21 @@ const prepareServer = ({ return startIsolate } +interface InspectSettings { + // Inspect mode enabled + enabled: boolean + + // Pause on breakpoints (i.e. "--brk") + pause: boolean + + // Host/port override (optional) + address?: string +} interface ServeOptions { certificatePath?: string debug?: boolean distImportMapPath?: string - edgeInspect?: boolean | string - edgeInspectBrk?: boolean | string + inspectSettings?: InspectSettings importMaps?: ImportMapFile[] onAfterDownload?: LifecycleHook onBeforeDownload?: LifecycleHook @@ -90,8 +99,7 @@ const serve = async ({ certificatePath, debug, distImportMapPath, - edgeInspect, - edgeInspectBrk, + inspectSettings, formatExportTypeError, formatImportError, importMaps, @@ -127,12 +135,12 @@ const serve = async ({ flags.push('--quiet') } - if (edgeInspect) { - flags.push(typeof edgeInspect === 'boolean' ? '--inspect' : `--inspect${edgeInspect}`) - } - - if (edgeInspectBrk) { - flags.push(typeof edgeInspectBrk === 'boolean' ? '--inspect-brk' : `--inspect-brk${edgeInspectBrk}`) + if (inspectSettings && inspectSettings.enabled) { + if (inspectSettings.pause) { + flags.push(inspectSettings.address ? `--inspect-brk${inspectSettings.address}` : '--inspect-brk') + } else { + flags.push(inspectSettings.address ? `--inspect${inspectSettings.address}` : '--inspect') + } } const server = await prepareServer({ From 59f2da580eeecdd35f275c05c681829c73276410 Mon Sep 17 00:00:00 2001 From: Jackie Macharia Date: Wed, 25 May 2022 15:27:40 +0300 Subject: [PATCH 3/3] fix: add the = from bundler instead --- src/server/server.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/server.ts b/src/server/server.ts index 22e27bd1..1cd793a3 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -137,9 +137,9 @@ const serve = async ({ if (inspectSettings && inspectSettings.enabled) { if (inspectSettings.pause) { - flags.push(inspectSettings.address ? `--inspect-brk${inspectSettings.address}` : '--inspect-brk') + flags.push(inspectSettings.address ? `--inspect-brk=${inspectSettings.address}` : '--inspect-brk') } else { - flags.push(inspectSettings.address ? `--inspect${inspectSettings.address}` : '--inspect') + flags.push(inspectSettings.address ? `--inspect=${inspectSettings.address}` : '--inspect') } }