From 9c58c5d7420ebf53894944326ef065beae64b12f Mon Sep 17 00:00:00 2001 From: Narendranath Gogineni Date: Wed, 11 Sep 2024 19:21:36 +0530 Subject: [PATCH 1/9] exclude test files from typescript compilation --- tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index a5682c974..34311469f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,5 +11,6 @@ "jsx": "react-jsx", "jsxImportSource": "hono/jsx", "resolveJsonModule": true - } + }, + "exclude": ["**/*.test.ts"] } From 6e9b2e23719ff73e7596990d62154f696fa435da Mon Sep 17 00:00:00 2001 From: Narendranath Gogineni Date: Wed, 11 Sep 2024 19:22:48 +0530 Subject: [PATCH 2/9] add sourcemap support and build dir --- tsconfig.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 34311469f..85075031b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,7 +10,9 @@ "types": ["@cloudflare/workers-types", "node", "jest"], "jsx": "react-jsx", "jsxImportSource": "hono/jsx", - "resolveJsonModule": true + "resolveJsonModule": true, + "sourceMap": true, + "outDir": "./build" }, "exclude": ["**/*.test.ts"] } From 6ae985f66122c836b7c8347eb3addc658cb05c66 Mon Sep 17 00:00:00 2001 From: Narendranath Gogineni Date: Wed, 11 Sep 2024 19:24:04 +0530 Subject: [PATCH 3/9] define task for compilation --- .vscode/tasks.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .vscode/tasks.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000..ab5190365 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,18 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "type": "shell", + "label": "npx tsc", + "command": "npx", + "args": ["tsc"], + "problemMatcher": ["$tsc"], + "group": { + "kind": "build", + "isDefault": true + } + } + ] +} From 7366d85e2de29e061cde3eaf3571ad25db5bbd2c Mon Sep 17 00:00:00 2001 From: Narendranath Gogineni Date: Wed, 11 Sep 2024 19:24:35 +0530 Subject: [PATCH 4/9] debug launch.json for vscode --- .vscode/launch.json | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..5306c1b0b --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Debug Gateway launched with node environment", + "runtimeExecutable": "tsx", + "runtimeArgs": ["${workspaceFolder}/build/src/start-server.js"], + "sourceMaps": true, + "outFiles": ["${workspaceFolder}/build/**/*.js"], + "sourceMapPathOverrides": { + "../src/*": "${workspaceFolder}/src/*" + }, + "skipFiles": ["/**"], + "preLaunchTask": "npx tsc", + "console": "integratedTerminal", + "internalConsoleOptions": "neverOpen" + } + ] +} From d112168c9beee775389f8018622d20f1e691bad3 Mon Sep 17 00:00:00 2001 From: Narendranath Gogineni Date: Thu, 12 Sep 2024 10:04:42 +0530 Subject: [PATCH 5/9] Add debug config for wrangler --- .vscode/launch.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.vscode/launch.json b/.vscode/launch.json index 5306c1b0b..0b1671512 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,6 +4,16 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { + "name": "Wrangler", + "type": "node", + "request": "attach", + "port": 9229, + "cwd": "/", + "resolveSourceMapLocations": null, + "attachExistingChildren": false, + "autoAttachChildProcesses": false + }, { "type": "node", "request": "launch", From ac159671b1d68764cf2cd51819237f798a195adc Mon Sep 17 00:00:00 2001 From: Narendranath Gogineni Date: Thu, 12 Sep 2024 10:07:49 +0530 Subject: [PATCH 6/9] update names --- .vscode/launch.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 0b1671512..fd56e31f9 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,7 +5,7 @@ "version": "0.2.0", "configurations": [ { - "name": "Wrangler", + "name": "Wrangler debug", "type": "node", "request": "attach", "port": 9229, @@ -17,7 +17,7 @@ { "type": "node", "request": "launch", - "name": "Debug Gateway launched with node environment", + "name": "Node debug", "runtimeExecutable": "tsx", "runtimeArgs": ["${workspaceFolder}/build/src/start-server.js"], "sourceMaps": true, From 6544e1b533274d53361f0efd4b9a9b5c26b89bdd Mon Sep 17 00:00:00 2001 From: Narendranath Gogineni Date: Thu, 12 Sep 2024 10:10:01 +0530 Subject: [PATCH 7/9] added comment on how to use debugger --- .vscode/launch.json | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index fd56e31f9..101283e93 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,7 +1,14 @@ { - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + /* + 1. steps to run wrangler debugger (https://blog.cloudflare.com/debugging-cloudflare-workers/) + - run `npm run dev` in a terminal + - in debug and run tab, select 'Wrangler debug' and run + - add a breakpoint and verify + + 2. Steps tp run node debugger + - In debug tab select "Node debug" and run + - add a breakpoint and verify + */ "version": "0.2.0", "configurations": [ { From f3713105a75d1b3fc51969df4619052fe9b23f11 Mon Sep 17 00:00:00 2001 From: Narendranath Gogineni Date: Thu, 12 Sep 2024 10:35:41 +0530 Subject: [PATCH 8/9] Don't generate sourcemap for regular builds to reduce build size --- tsconfig.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 85075031b..34311469f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,9 +10,7 @@ "types": ["@cloudflare/workers-types", "node", "jest"], "jsx": "react-jsx", "jsxImportSource": "hono/jsx", - "resolveJsonModule": true, - "sourceMap": true, - "outDir": "./build" + "resolveJsonModule": true }, "exclude": ["**/*.test.ts"] } From 3f24b63a891aaa2cb86a799edf93f8730f8c0b3d Mon Sep 17 00:00:00 2001 From: Narendranath Gogineni Date: Thu, 12 Sep 2024 10:36:01 +0530 Subject: [PATCH 9/9] Cleanup build containing map files after debugging is done --- .vscode/launch.json | 3 ++- .vscode/tasks.json | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 101283e93..12004c54a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -35,7 +35,8 @@ "skipFiles": ["/**"], "preLaunchTask": "npx tsc", "console": "integratedTerminal", - "internalConsoleOptions": "neverOpen" + "internalConsoleOptions": "neverOpen", + "postDebugTask": "cleanup build" } ] } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index ab5190365..bd050a834 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -7,12 +7,30 @@ "type": "shell", "label": "npx tsc", "command": "npx", - "args": ["tsc"], + "args": [ + "tsc", + "--sourcemap", + "true", + "--outDir", + "${workspaceFolder}/build" + ], "problemMatcher": ["$tsc"], "group": { "kind": "build", "isDefault": true } + }, + { + "type": "shell", + "label": "cleanup build", + "command": "rm", + "args": ["-rf", "${workspaceFolder}/build"], + "problemMatcher": [], + "group": "build", + "presentation": { + "reveal": "always", + "panel": "new" + } } ] }