chore: unify the repo on TypeScript — tests, vitest config, and the social-preview generator move from .mjs to .ts

vitest (esbuild) and Node 24 type stripping run the .ts files directly;
helper imports go extensionless like src. Typecheck stays scoped to src/
as before.
This commit is contained in:
bowenliang123 committed 2026-08-23 05:11:27 +08:00
1 parent 4b8d00ee03
commit 57ff90dfc3
22 files changed
+26 -26

No files matched your search

@@ -1,7 +1,7 @@
// Renders social-preview.html to docs/social-preview.png (exactly 1280x640).
// Renders at 2x (2560x1280) first, then downsamples via Chromium's high-quality
// image smoothing, so text and the embedded screenshot stay sharp.
// Usage: node docs/social-preview/generate.mjs (or: npm run social-preview)
// Usage: node docs/social-preview/generate.ts (or: npm run social-preview)
import { chromium } from 'playwright-core';
import { homedir } from 'node:os';
import { fileURLToPath, pathToFileURL } from 'node:url';
+1 -1
View File
@@ -40,7 +40,7 @@
"test": "npm run typecheck && vitest run",
"release": "bash scripts/publish.sh",
"hooks": "bash scripts/install-hooks.sh",
"social-preview": "node docs/social-preview/generate.mjs"
"social-preview": "node docs/social-preview/generate.ts"
},
"dsh": {
"bundle": {
@@ -9,7 +9,7 @@
*/
import assert from 'node:assert/strict'
import { test } from 'vitest'
import { bootViewBed, byClass, textOf } from './helpers/viewBed.mjs'
import { bootViewBed, byClass, textOf } from './helpers/viewBed'
const bed = await bootViewBed()
const { renderView, snapshot } = bed
@@ -5,7 +5,7 @@
*/
import assert from 'node:assert/strict'
import { test } from 'vitest'
import { bootViewBed, byClass, textOf } from './helpers/viewBed.mjs'
import { bootViewBed, byClass, textOf } from './helpers/viewBed'
const bed = await bootViewBed()
const { renderView, snapshot } = bed
@@ -6,7 +6,7 @@
*/
import assert from 'node:assert/strict'
import { test } from 'vitest'
import { bootViewBed, byClass, catRowOf, textOf } from './helpers/viewBed.mjs'
import { bootViewBed, byClass, catRowOf, textOf } from './helpers/viewBed'
const bed = await bootViewBed()
const { hookStates, renderView, snapshot } = bed
+1 -1
View File
@@ -7,7 +7,7 @@
import assert from 'node:assert/strict'
import { readFile } from 'node:fs/promises'
import { test } from 'vitest'
import { bootViewBed, byClass, plainText, textOf } from './helpers/viewBed.mjs'
import { bootViewBed, byClass, plainText, textOf } from './helpers/viewBed'
const bed = await bootViewBed()
const { hookStates, renderView, snapshot } = bed
@@ -8,7 +8,7 @@
import assert from 'node:assert/strict'
import { readFile } from 'node:fs/promises'
import { test } from 'vitest'
import { bootViewBed, FAKE_PRIMITIVES, makeFakeDoc } from './helpers/viewBed.mjs'
import { bootViewBed, FAKE_PRIMITIVES, makeFakeDoc } from './helpers/viewBed'
const bundle = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
@@ -5,7 +5,7 @@
*/
import assert from 'node:assert/strict'
import { test } from 'vitest'
import { bootViewBed, byClass, catRowOf, textOf } from './helpers/viewBed.mjs'
import { bootViewBed, byClass, catRowOf, textOf } from './helpers/viewBed'
const bed = await bootViewBed()
const { renderView, snapshot } = bed
+2 -2
View File
@@ -25,7 +25,7 @@
* canonicalHeader is identity — stored headers are already canonical).
*
* Usage:
* bun tests/diff-fold.mjs <session.jsonl> [more.jsonl...]
* bun tests/diff-fold.ts <session.jsonl> [more.jsonl...]
* zstd -dc ~/.dsh/sessions/<ws>/<sid>/session.jsonl.zstd > /tmp/s.jsonl
*
* Exit code 0 when every log matches, 1 otherwise.
@@ -89,7 +89,7 @@ function imageDeltaOf(blocks) {
const files = process.argv.slice(2)
if (files.length === 0) {
console.error('usage: bun tests/diff-fold.mjs <session.jsonl> [...]')
console.error('usage: bun tests/diff-fold.ts <session.jsonl> [...]')
process.exit(2)
}
File renamed without changes.
@@ -11,7 +11,7 @@ import assert from 'node:assert/strict'
import { readFile } from 'node:fs/promises'
import { join } from 'node:path'
import { test } from 'vitest'
import { FAKE_PRIMITIVES } from './helpers/viewBed.mjs'
import { FAKE_PRIMITIVES } from './helpers/viewBed'
test('client HMR safety: fiber dispose removes every registration', async () => {
const bundle = await readFile(join(process.cwd(), 'lib/client.js'), 'utf8')
File renamed without changes.
File renamed without changes.
@@ -5,7 +5,7 @@
*/
import assert from 'node:assert/strict'
import { test } from 'vitest'
import { bootViewBed, byClass, textOf } from './helpers/viewBed.mjs'
import { bootViewBed, byClass, textOf } from './helpers/viewBed'
const bed = await bootViewBed()
const { hookStates, renderView, snapshot } = bed
@@ -5,7 +5,7 @@
*/
import assert from 'node:assert/strict'
import { test } from 'vitest'
import { bootViewBed, byClass, textOf } from './helpers/viewBed.mjs'
import { bootViewBed, byClass, textOf } from './helpers/viewBed'
const bed = await bootViewBed()
const { renderView, snapshot } = bed
+1 -1
View File
@@ -5,7 +5,7 @@
*/
import assert from 'node:assert/strict'
import { test } from 'vitest'
import { bootViewBed, byClass, textOf } from './helpers/viewBed.mjs'
import { bootViewBed, byClass, textOf } from './helpers/viewBed'
const bed = await bootViewBed()
const { bailCalls, evaluate, modalComponent, modalSource, snapshot } = bed
File renamed without changes.
File renamed without changes.
@@ -6,7 +6,7 @@
*/
import assert from 'node:assert/strict'
import { test } from 'vitest'
import { bootViewBed, byClass, textOf } from './helpers/viewBed.mjs'
import { bootViewBed, byClass, textOf } from './helpers/viewBed'
const bed = await bootViewBed()
const { classInstances, evaluate, modalComponent, renderView, snapshot, viewComponent } = bed
@@ -5,7 +5,7 @@
*/
import assert from 'node:assert/strict'
import { test } from 'vitest'
import { bootViewBed, byClass, textOf } from './helpers/viewBed.mjs'
import { bootViewBed, byClass, textOf } from './helpers/viewBed'
const bed = await bootViewBed()
const { renderView, snapshot } = bed
-10
View File
@@ -1,10 +0,0 @@
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
// Specs exercise the BUILT artifacts (lib/), so `pnpm run build` first.
// `*.client.spec.mjs` is the browser lane (jsdom pragma per file); the
// plain `*.spec.mjs` files run in node with their own fakes.
include: ['tests/**/*.spec.mjs'],
},
})
+10
View File
@@ -0,0 +1,10 @@
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
// Specs exercise the BUILT artifacts (lib/), so `pnpm run build` first.
// `*.client.spec.ts` is the browser lane (jsdom pragma per file); the
// plain `*.spec.ts` files run in node with their own fakes.
include: ['tests/**/*.spec.ts'],
},
})