Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,37 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Cache Docker images
uses: actions/cache@v3
with:
path: /tmp/docker-images
key: docker-${{ runner.os }}-postgres15-mysql8
restore-keys: |
docker-${{ runner.os }}-

- name: Load Docker images
run: |
if [ -f /tmp/docker-images/postgres.tar ]; then
docker load -i /tmp/docker-images/postgres.tar
fi
if [ -f /tmp/docker-images/mysql.tar ]; then
docker load -i /tmp/docker-images/mysql.tar
fi

- name: Run Test
shell: bash
run: |
cd test
./test.sh
npm run test

- name: Save Docker images
if: always()
run: |
mkdir -p /tmp/docker-images
docker pull postgres:15 2>/dev/null || true
docker pull mysql:8.0 2>/dev/null || true
docker save postgres:15 -o /tmp/docker-images/postgres.tar 2>/dev/null || true
docker save mysql:8.0 -o /tmp/docker-images/mysql.tar 2>/dev/null || true

test_template:
runs-on: ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"private": true,
"scripts": {
"docs": "typedoc",
"test": "cd test && ./test.sh"
"test": "cd test && npm run test"
},
"repository": {
"type": "git",
Expand Down
File renamed without changes.
14 changes: 14 additions & 0 deletions test/apps/debugger-testing/chained-sourcemaps/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "starlingmonkey",
"request": "launch",
"name": "Debug StarlingMonkey component",
"component": "${workspaceFolder}/dist/chained-sourcemaps.wasm",
"program": "${workspaceFolder}/src/index.ts",
"stopOnEntry": false,
"trace": true
}
]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `http-js` Template
# `http-ts` Template

A starter template for building JavaScript HTTP applications with Spin.
A starter template for building TypeScript HTTP applications with Spin.

## Getting Started

Expand Down Expand Up @@ -29,4 +29,11 @@ To use additional Spin interfaces, install the corresponding packages:
| PostgreSQL | `@spinframework/spin-postgres` |
| Redis | `@spinframework/spin-redis` |
| SQLite | `@spinframework/spin-sqlite` |
| Variables | `@spinframework/spin-variables` |
| Variables | `@spinframework/spin-variables` |

## Using the StarlingMonkey Debugger for VS Code

1. First install the [StarlingMonkey Debugger](https://marketplace.visualstudio.com/items?itemName=BytecodeAlliance.starlingmonkey-debugger) extension.
2. Build the component using the debug command `npm run build:debug`.
3. Uncomment `tcp://127.0.0.1:*` in the `allowed_outbound_hosts` field in the `spin.toml`.
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.
42 changes: 42 additions & 0 deletions test/apps/debugger-testing/chained-sourcemaps/build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// build.mjs
import { build } from 'esbuild';
import path from 'path';
import { SpinEsbuildPlugin } from "@spinframework/build-tools/plugins/esbuild/index.js";
import fs from 'fs';

const spinPlugin = await SpinEsbuildPlugin();

// plugin to handle vendor files in node_modules that may not be bundled.
// Instead of generating a real source map for these files, it appends a minimal
// inline source map pointing to an empty source. This avoids errors and ensures
// source maps exist even for unbundled vendor code.
let SourceMapPlugin = {
name: 'excludeVendorFromSourceMap',
setup(build) {
build.onLoad({ filter: /node_modules/ }, args => {
return {
contents: fs.readFileSync(args.path, 'utf8')
+ '\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIiJdLCJtYXBwaW5ncyI6IkEifQ==',
loader: 'default',
}
})
},
}

await build({
entryPoints: ['./src/index.ts'],
outfile: './build/bundle.js',
bundle: true,
format: 'esm',
platform: 'node',
sourcemap: true,
minify: false,
plugins: [spinPlugin, SourceMapPlugin],
logLevel: 'error',
loader: {
'.ts': 'ts',
'.tsx': 'tsx',
},
resolveExtensions: ['.ts', '.tsx', '.js'],
sourceRoot: path.resolve(process.cwd(), 'src'),
});
Loading