From 8deacb5d506ddc3ece76683a9d5e0b27228e0810 Mon Sep 17 00:00:00 2001 From: Derek J <127624400+heyderekj@users.noreply.github.com> Date: Thu, 12 Nov 2026 20:14:10 -0600 Subject: [PATCH] sdk: npm install docs, and an async type test that can't time out - The package is on npm (0.2.0 and 0.3.0 are published), so the README, quickstart and React docs show npm install instead of "not published". - types.test runs tsc through async execFile. Seven blocking execFileSync calls could hold the test worker past Vitest's 60 s RPC timeout on a busy machine, failing the run with "Timeout calling onTaskUpdate" though every test passed. Co-Authored-By: Claude Opus 5.5 --- docs/quickstart.md | 2 +- docs/react.md | 2 +- packages/sdk/README.md | 10 +++++++++- packages/sdk/test/types.test.ts | 31 +++++++++++++++++++------------ 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/docs/quickstart.md b/docs/quickstart.md index ab395ab..317ba56 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -70,8 +70,8 @@ const { results } = await lookup.search("grace comm"); const church = await lookup.getChurch(results[0].id); ``` ```bash title="npm" -# Coming soon. The package isn't published yet. npm install @heresmychurch/lookup +# then, once in your app: import "@heresmychurch/lookup/element"; ``` ::: diff --git a/docs/react.md b/docs/react.md index bff063f..9550e3b 100644 --- a/docs/react.md +++ b/docs/react.md @@ -31,7 +31,7 @@ Add a church picker to this React + shadcn/ui app using Lookup by Here's My Chur Check: type "grac", pick a church, the tagged fields fill and handleSubmit receives church_id. ::: -Not on shadcn/ui? Use the element with `onchurch-select` props in React 19 (see [the widget](/docs/widget#in-your-form)), or build your own picker with `useChurchLookup` from `@heresmychurch/lookup/react` once the package is on npm. +Not on shadcn/ui? Use the element with `onchurch-select` props in React 19 (see [the widget](/docs/widget#in-your-form)), or build your own picker with `useChurchLookup` from `@heresmychurch/lookup/react` (`npm install @heresmychurch/lookup`). ## Install diff --git a/packages/sdk/README.md b/packages/sdk/README.md index 12b7101..4d0e15a 100644 --- a/packages/sdk/README.md +++ b/packages/sdk/README.md @@ -2,7 +2,15 @@ Church typeahead and autofill from [Here's My Church](https://heresmychurch.com). MIT, no dependencies. -Not published to npm yet. Until it is, load the element from the API: +```bash +npm install @heresmychurch/lookup +``` + +```js +import "@heresmychurch/lookup/element"; +``` + +Or load the element with no build step: ```html diff --git a/packages/sdk/test/types.test.ts b/packages/sdk/test/types.test.ts index 347f785..df5c8a8 100644 --- a/packages/sdk/test/types.test.ts +++ b/packages/sdk/test/types.test.ts @@ -1,7 +1,8 @@ // Run after `node scripts/build.mjs`, which `pnpm test` does. Checks the published types work for an // app: every export has a declaration, none import ".ts" files an app can't resolve, and an app finds // them under each moduleResolution TypeScript offers, including the older "node" (node10). -import { execFileSync } from "node:child_process"; +import { execFile } from "node:child_process"; +import { promisify } from "node:util"; import { copyFileSync, cpSync, existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, symlinkSync, writeFileSync } from "node:fs"; import { createRequire } from "node:module"; import { tmpdir } from "node:os"; @@ -11,6 +12,13 @@ import { afterAll, describe, expect, it } from "vitest"; const root = process.cwd(); const pkg = JSON.parse(readFileSync(`${root}/package.json`, "utf8")); const tsc = createRequire(import.meta.url).resolve("typescript/bin/tsc"); +// Async, so a slow tsc never blocks the test worker long enough for Vitest's RPC to time out. +const run = promisify(execFile); +/** tsc's errors for a project, or "" when it type-checks. */ +async function tscErrors(project: string, cwd: string): Promise { + try { await run(process.execPath, [tsc, "-p", project], { cwd }); return ""; } + catch (e) { return String((e as { stdout?: string }).stdout || e); } +} // A throwaway app with the package in node_modules the way an install puts it: package.json and dist. const app = mkdtempSync(join(tmpdir(), "lookup-types-")); @@ -31,12 +39,11 @@ writeFileSync(join(app, "node_modules/vue/package.json"), JSON.stringify({ name: writeFileSync(join(app, "node_modules/vue/index.d.ts"), "export type DefineComponent

= { new (): { $props: P } };\nexport interface GlobalComponents {}\n"); afterAll(() => rmSync(app, { recursive: true, force: true })); -function typecheck(moduleResolution: string, module: string, type: "module" | "commonjs", files = ["consumer.ts"]) { +async function typecheck(moduleResolution: string, module: string, type: "module" | "commonjs", files = ["consumer.ts"]) { writeFileSync(join(app, "package.json"), JSON.stringify({ type })); const compilerOptions = { target: "ES2022", module, moduleResolution, lib: ["ES2022", "DOM", "DOM.Iterable"], types: [], strict: true, noEmit: true, skipLibCheck: false, jsx: "react-jsx" }; writeFileSync(join(app, "tsconfig.json"), JSON.stringify({ compilerOptions, files })); - try { execFileSync(process.execPath, [tsc, "-p", "tsconfig.json"], { cwd: app, stdio: "pipe" }); return ""; } - catch (e) { return String((e as { stdout?: Buffer }).stdout ?? e); } + return tscErrors("tsconfig.json", app); } describe("published types", () => { @@ -61,21 +68,21 @@ describe("published types", () => { expect(readFileSync(`${root}/dist/${f}`, "utf8"), f).not.toMatch(/(from|import\()\s*["']\.\/[^"']*\.ts["']/); } }); - it("type-checks in an app with the original settings (self-reference)", () => { - expect(() => execFileSync(process.execPath, [tsc, "-p", "test/types/tsconfig.json"], { cwd: root, stdio: "pipe" })).not.toThrow(); + it("type-checks in an app with the original settings (self-reference)", async () => { + expect(await tscErrors("test/types/tsconfig.json", root)).toBe(""); }, 60_000); it.each([ ["bundler", "esnext", "module"], ["node16", "node16", "module"], ["nodenext", "nodenext", "module"], ["node10", "commonjs", "commonjs"], - ] as const)("type-checks in an app with moduleResolution %s", (mr, m, type) => { - expect(typecheck(mr, m, type)).toBe(""); + ] as const)("type-checks in an app with moduleResolution %s", async (mr, m, type) => { + expect(await typecheck(mr, m, type)).toBe(""); }, 60_000); - it("types React 19 props, events and the hook", () => { - expect(typecheck("bundler", "esnext", "module", ["consumer-react.tsx"])).toBe(""); + it("types React 19 props, events and the hook", async () => { + expect(await typecheck("bundler", "esnext", "module", ["consumer-react.tsx"])).toBe(""); }, 60_000); - it("types Vue template events", () => { - expect(typecheck("bundler", "esnext", "module", ["consumer-vue.ts"])).toBe(""); + it("types Vue template events", async () => { + expect(await typecheck("bundler", "esnext", "module", ["consumer-vue.ts"])).toBe(""); }, 60_000); });