From 89629a7f08be57c867a37d9b256d50bebf6b738d Mon Sep 17 00:00:00 2001 From: shenowen Date: Mon, 4 Oct 2021 13:56:38 -0500 Subject: [PATCH] Add inspectBrk to try to use when debugging backend node Signed-off-by: shenowen --- packages/cli/src/commands/backend/dev.ts | 1 + packages/cli/src/commands/index.ts | 1 + packages/cli/src/lib/bundler/config.ts | 2 +- packages/cli/src/lib/bundler/types.ts | 2 ++ 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/commands/backend/dev.ts b/packages/cli/src/commands/backend/dev.ts index a09cea0e8a..b14a1f3e20 100644 --- a/packages/cli/src/commands/backend/dev.ts +++ b/packages/cli/src/commands/backend/dev.ts @@ -29,6 +29,7 @@ export default async (cmd: Command) => { entry: 'src/index', checksEnabled: cmd.check, inspectEnabled: cmd.inspect, + inspectBrkEnabled: cmd.inspectBrk, }); await waitForExit(); diff --git a/packages/cli/src/commands/index.ts b/packages/cli/src/commands/index.ts index bcd1509f58..117778b35e 100644 --- a/packages/cli/src/commands/index.ts +++ b/packages/cli/src/commands/index.ts @@ -69,6 +69,7 @@ export function registerCommands(program: CommanderStatic) { .description('Start local development server with HMR for the backend') .option('--check', 'Enable type checking and linting') .option('--inspect', 'Enable debugger') + .option('--inspect-brk', 'Enable debugger with await to attach debugger') // We don't actually use the config in the CLI, just pass them on to the NodeJS process .option(...configOption) .action(lazy(() => import('./backend/dev').then(m => m.default))); diff --git a/packages/cli/src/lib/bundler/config.ts b/packages/cli/src/lib/bundler/config.ts index 6e3f445f4a..964f12535d 100644 --- a/packages/cli/src/lib/bundler/config.ts +++ b/packages/cli/src/lib/bundler/config.ts @@ -319,7 +319,7 @@ export async function createBackendConfig( plugins: [ new RunScriptWebpackPlugin({ name: 'main.js', - nodeArgs: options.inspectEnabled ? ['--inspect'] : undefined, + nodeArgs: options.inspectEnabled ? ['--inspect'] : options.inspectEnabled ? ['--inspect-brk'] : undefined, args: process.argv.slice(3), // drop `node backstage-cli backend:dev` }), new webpack.HotModuleReplacementPlugin(), diff --git a/packages/cli/src/lib/bundler/types.ts b/packages/cli/src/lib/bundler/types.ts index 283074a295..93865bcf7e 100644 --- a/packages/cli/src/lib/bundler/types.ts +++ b/packages/cli/src/lib/bundler/types.ts @@ -47,11 +47,13 @@ export type BackendBundlingOptions = { isDev: boolean; parallel?: ParallelOption; inspectEnabled: boolean; + inspectBrkEnabled: boolean; }; export type BackendServeOptions = BundlingPathsOptions & { checksEnabled: boolean; inspectEnabled: boolean; + inspectBrkEnabled: boolean; }; export type LernaPackage = {