Refactor build to produce source-map for node debugging

Signed-off-by: 20k-ultra <3946250+20k-ultra@users.noreply.github.com>
This commit is contained in:
20k-ultra 2022-03-23 18:16:19 -04:00
parent 5513a9a045
commit 37f23d670d
5 changed files with 30 additions and 3 deletions

20
.vscode/launch.json vendored Normal file
View File

@ -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"
}
]
}

View File

@ -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 `<device-local-ip>: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.

View File

@ -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

View File

@ -6,7 +6,7 @@
"strictFunctionTypes": false,
"strictPropertyInitialization": false,
"preserveConstEnums": true,
"inlineSourceMap": true,
"sourceMap": true,
"outDir": "./build/",
"skipLibCheck": true,
"lib": ["es2019"],

View File

@ -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'],