Merge pull request #7438 from AmericanAirlines/node-inspect-break-debugging

Add inspectBrk to try to use when debugging backend node
This commit is contained in:
Fredrik Adelöw
2021-10-07 12:58:51 +02:00
committed by GitHub
5 changed files with 17 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/cli': patch
---
Adding `--inspect-brk` as an option when debugging backend for development
+1
View File
@@ -29,6 +29,7 @@ export default async (cmd: Command) => {
entry: 'src/index',
checksEnabled: cmd.check,
inspectEnabled: cmd.inspect,
inspectBrkEnabled: cmd.inspectBrk,
});
await waitForExit();
+1
View File
@@ -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)));
+8 -1
View File
@@ -247,6 +247,13 @@ export async function createBackendConfig(
const { loaders } = transforms(options);
const runScriptNodeArgs = new Array<string>();
if (options.inspectEnabled) {
runScriptNodeArgs.push('--inspect');
} else if (options.inspectBrkEnabled) {
runScriptNodeArgs.push('--inspect-brk');
}
return {
mode: isDev ? 'development' : 'production',
profile: false,
@@ -319,7 +326,7 @@ export async function createBackendConfig(
plugins: [
new RunScriptWebpackPlugin({
name: 'main.js',
nodeArgs: options.inspectEnabled ? ['--inspect'] : undefined,
nodeArgs: runScriptNodeArgs.length > 0 ? runScriptNodeArgs : undefined,
args: process.argv.slice(3), // drop `node backstage-cli backend:dev`
}),
new webpack.HotModuleReplacementPlugin(),
+2
View File
@@ -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 = {