Skip to content

Commit 1de996e

Browse files
committed
make the setup to use debugger easier
Add a readme note on how to use the debugger. Also adds a commented out outbound host for debugger connection and a npm script to build debug. Signed-off-by: Karthik Ganeshram <karthik.ganeshram@fermyon.com>
1 parent f21210f commit 1de996e

File tree

7 files changed

+25
-3
lines changed

7 files changed

+25
-3
lines changed

templates/http-js/content/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,11 @@ To use additional Spin interfaces, install the corresponding packages:
2929
| PostgreSQL | `@spinframework/spin-postgres` |
3030
| Redis | `@spinframework/spin-redis` |
3131
| SQLite | `@spinframework/spin-sqlite` |
32-
| Variables | `@spinframework/spin-variables` |
32+
| Variables | `@spinframework/spin-variables` |
33+
34+
## Using the StarlingMonkey Debugger for VS Code
35+
36+
1. First install the [StarlingMonkey Debugger](https://marketplace.visualstudio.com/items?itemName=BytecodeAlliance.starlingmonkey-debugger) extension.
37+
2. Build the component using the debug command `npm run build:debug`.
38+
3. Uncomment `tcp://127.0.0.1:*` in the `allowed_outbound_hosts` field in the `spin.toml`.
39+
4. Start the debugger in VS Code which should start Spin and attach the debugger. The debugger needs to be restarted for each http call.

templates/http-js/content/build.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ let SourceMapPlugin = {
2424
}
2525

2626
await build({
27-
entryPoints: ['./src/index.ts'],
27+
entryPoints: ['./src/index.js'],
2828
outfile: './build/bundle.js',
2929
bundle: true,
3030
format: 'esm',

templates/http-js/content/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"main": "index.js",
66
"scripts": {
77
"build": "node build.mjs && mkdirp dist && j2w -i build/bundle.js --initLocation http://{{project-name | kebab_case}}.localhost -o dist/{{ project-name | kebab_case }}.wasm",
8+
"build:debug": "node build.mjs && mkdirp dist && j2w -d -i build/bundle.js --initLocation http://{{project-name | kebab_case}}.localhost -o dist/{{ project-name | kebab_case }}.wasm",
89
"test": "echo \"Error: no test specified\" && exit 1"
910
},
1011
"keywords": [],

templates/http-js/content/spin.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ component = "{{project-name | kebab_case}}"
1313
[component.{{project-name | kebab_case}}]
1414
source = "dist/{{project-name | kebab_case}}.wasm"
1515
exclude_files = ["**/node_modules"]
16+
allowed_outbound_hosts = [
17+
# "tcp://127.0.0.1:*", # Uncomment this line to while using the StarlingMonkey Debugger
18+
]
1619
[component.{{project-name | kebab_case}}.build]
1720
command = ["npm install", "npm run build"]
1821
watch = ["src/**/*.js"]

templates/http-ts/content/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,11 @@ To use additional Spin interfaces, install the corresponding packages:
2929
| PostgreSQL | `@spinframework/spin-postgres` |
3030
| Redis | `@spinframework/spin-redis` |
3131
| SQLite | `@spinframework/spin-sqlite` |
32-
| Variables | `@spinframework/spin-variables` |
32+
| Variables | `@spinframework/spin-variables` |
33+
34+
## Using the StarlingMonkey Debugger for VS Code
35+
36+
1. First install the [StarlingMonkey Debugger](https://marketplace.visualstudio.com/items?itemName=BytecodeAlliance.starlingmonkey-debugger) extension.
37+
2. Build the component using the debug command `npm run build:debug`.
38+
3. Uncomment `tcp://127.0.0.1:*` in the `allowed_outbound_hosts` field in the `spin.toml`.
39+
4. Start the debugger in VS Code which should start Spin and attach the debugger. The debugger needs to be restarted for each http call.

templates/http-ts/content/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"main": "index.js",
66
"scripts": {
77
"build": "node build.mjs && mkdirp dist && j2w -i build/bundle.js --initLocation http://{{project-name | kebab_case}}.localhost -o dist/{{ project-name | kebab_case }}.wasm",
8+
"build:debug": "node build.mjs && mkdirp dist && j2w -d -i build/bundle.js --initLocation http://{{project-name | kebab_case}}.localhost -o dist/{{ project-name | kebab_case }}.wasm",
89
"test": "echo \"Error: no test specified\" && exit 1"
910
},
1011
"keywords": [],

templates/http-ts/content/spin.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ component = "{{project-name | kebab_case}}"
1313
[component.{{project-name | kebab_case}}]
1414
source = "dist/{{project-name | kebab_case}}.wasm"
1515
exclude_files = ["**/node_modules"]
16+
allowed_outbound_hosts = [
17+
# "tcp://127.0.0.1:*", # Uncomment this line to while using the StarlingMonkey Debugger
18+
]
1619
[component.{{project-name | kebab_case}}.build]
1720
command = ["npm install", "npm run build"]
1821
watch = ["src/**/*.ts"]

0 commit comments

Comments
 (0)