Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support for Edge Functions debugging #31

Merged
merged 5 commits into from
May 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +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
inspectSettings?: InspectSettings
importMaps?: ImportMapFile[]
onAfterDownload?: LifecycleHook
onBeforeDownload?: LifecycleHook
Expand All @@ -83,10 +94,12 @@ interface ServeOptions {
port: number
}

// eslint-disable-next-line complexity, max-statements
const serve = async ({
certificatePath,
debug,
distImportMapPath,
inspectSettings,
formatExportTypeError,
formatImportError,
importMaps,
Expand Down Expand Up @@ -122,6 +135,14 @@ const serve = async ({
flags.push('--quiet')
}

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({
deno,
distDirectory,
Expand Down