diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..f5bc52f8 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,20 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "attach", + "name": "Attach to remote", + "address": "127.0.0.1", + "port": 9229, + "cwd": "${workspaceRoot}", + "program": "${workspaceRoot}/src/app.ts", + "outFiles": [ + "${workspaceRoot}/dist/bundle.js" + ], + "sourceMaps": true, + "localRoot": "${workspaceFolder}", + "remoteRoot": "/usr/src/app" + } + ] +} diff --git a/README.md b/README.md index dd504590..7f7c8de1 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,12 @@ and sync any relevant file changes to the running supervisor container. It will then decide if the container should be restarted, or let nodemon handle the changes. +### Debugging + +Using live push the supervisor starts with remote debugging enabled via the --inspect flag. Use Chrome dev tools, or your IDE to [start a debugging session](https://nodejs.org/en/docs/guides/debugging-getting-started/#inspector-clients). + +Connect your debugger to `:9229` + ### Using balenaOS-in-container This process will allow you to run a development instance of the supervisor on your local computer. It is not recommended for production scenarios, but allows someone developing on the supervisor to test changes quickly. diff --git a/entry.sh b/entry.sh index 0e242e8d..70813223 100755 --- a/entry.sh +++ b/entry.sh @@ -58,7 +58,7 @@ modprobe ip6_tables || true if [ "${LIVEPUSH}" = "1" ]; then exec npx nodemon --watch src --watch typings --ignore tests -e js,ts,json \ - --exec node -r ts-node/register/transpile-only src/app.ts + --exec node -r ts-node/register/transpile-only --inspect=0.0.0.0 src/app.ts else exec node /usr/src/app/dist/app.js fi diff --git a/tsconfig.json b/tsconfig.json index 1ec3cc9e..dc5481b6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,7 @@ "strictFunctionTypes": false, "strictPropertyInitialization": false, "preserveConstEnums": true, - "inlineSourceMap": true, + "sourceMap": true, "outDir": "./build/", "skipLibCheck": true, "lib": ["es2019"], diff --git a/webpack.config.js b/webpack.config.js index e086a38c..5d5e14eb 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -70,11 +70,12 @@ console.log('Using the following dependencies as external:', externalModules); module.exports = function (env) { return { mode: env == null || !env.noOptimize ? 'production' : 'development', - devtool: 'none', + devtool: 'source-map', entry: './src/app.ts', output: { filename: 'app.js', path: path.resolve(__dirname, 'dist'), + devtoolModuleFilenameTemplate: '[absolute-resource-path]', }, resolve: { extensions: ['.js', '.ts', '.json'],