Skip to content

Commit b405534

Browse files
committed
chore(dev): one-command local testing via pnpm dev
Adds a `pnpm dev` workflow so changes to src/ can be verified in a real browser without a publish round-trip: - `local.html` imports the local `dist/index.mjs` build and points benchmarks at `./dist/benchmarks/` (instead of the unpkg URL). - `dev:build` runs `tsdown --watch`; `dev:serve` runs python's static server on :8000 and prints the URL on startup. - `index.html` redirects to `local.html` when `location.port === '8000'`, so landing on the default localhost route doesn't silently load the published esm.sh bundle. GitHub Pages production is unaffected.
1 parent 7afbb82 commit b405534

3 files changed

Lines changed: 34 additions & 0 deletions

File tree

index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
<html>
33
<head>
44
<meta charset="utf-8" />
5+
<script>
6+
// During `pnpm dev` the static server runs on :8000; redirect to the
7+
// local-dist page so refreshes pick up uncommitted source changes.
8+
if (location.port === '8000') location.replace('./local.html');
9+
</script>
510
<title>detect-gpu</title>
611
<style>
712
body {

local.html

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>detect-gpu (local)</title>
6+
<style>
7+
body {
8+
font-family: system-ui, sans-serif;
9+
font-size: 1.25em;
10+
padding: 2rem;
11+
}
12+
</style>
13+
</head>
14+
<body>
15+
<pre id="root">Detecting GPU…</pre>
16+
<script type="module">
17+
import { getGPUTier } from './dist/index.mjs';
18+
const result = await getGPUTier({ benchmarksURL: './dist/benchmarks' });
19+
document.getElementById('root').textContent = JSON.stringify(
20+
result,
21+
null,
22+
2
23+
);
24+
</script>
25+
</body>
26+
</html>

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
"test:watch": "vitest",
5959
"test:coverage": "vitest run --coverage",
6060
"build": "tsdown",
61+
"dev": "pnpm run --parallel /^dev:/",
62+
"dev:build": "tsdown --watch",
63+
"dev:serve": "echo 'open http://localhost:8000/local.html' && python3 -m http.server 8000",
6164
"update-benchmarks": "node ./scripts/update_benchmarks.ts"
6265
},
6366
"devDependencies": {

0 commit comments

Comments
 (0)