Skip to content

feat: support Node.js and publish to npm and JSR - #14

Merged
KyleJune merged 5 commits into
mainfrom
node-migration
Oct 10, 2026
Merged

KyleJune merged 5 commits into
mainfrom
node-migration

Conversation

@KyleJune

@KyleJune KyleJune commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Summary

Migrates @udibo/http-error from Deno to Node + TypeScript, cross-published to npm and JSR (slice 2 of udibo/udibo#2148). The public API of mod.ts is unchanged; the first release will be 0.12.0 (the commit analyzer, run as a dry run against this branch, computes 0.12.0 from 0.11.1).

  • src/mod.ts (moved with git mv), tests as src/*.test.ts, examples/hono.ts + test. The Oak example, deno.json, deno.lock, .vscode Deno settings, and the Deno workflows are removed.
  • @std/http/status is replaced by a typed status table inlined in src/status.ts (adapted from @std/http, MIT, attributed in the file). It is byte-for-byte equivalent to @std/http@1.0.22 for STATUS_CODE and STATUS_TEXT (verified once with a deepEqual script). Zero runtime dependencies and no node: imports in src/, so it works in browsers.
  • Erasable-only TypeScript (strict, erasableSyntaxOnly, verbatimModuleSyntax, isolatedDeclarations, rewriteRelativeImportExtensions, .ts import extensions, ES2022, NodeNext), built with TypeScript 7 tsc to dist/ (ESM + .d.ts).
  • pnpm 12.10.1 with minimumReleaseAge: 4320 (@udibo/* excluded), .nvmrc 26, engines.node >=22, lockfile committed.
  • oxlint (type-aware and type-checking) + oxfmt; Vitest 5 with @vitest/coverage-v8 (text + lcov).
  • Tests ported to Vitest. Every behavioral assertion is kept; brittle ones are tightened (explicit default-name/exposed-message tables instead of tables derived from the implementation, an unconditional statusText assertion, no match on V8's JSON error text). New tests cover old-format name conversion, exposed-message defaults per status, the status table, and the in-process Hono example (app.request(), no subprocess).
  • scripts/npm-smoke.ts (Node, type stripping): pnpm pack, installs the tarball in an empty project, checks the tarball contents and zero dependencies, type-checks a consumer under NodeNext, runs it.
  • .github/workflows/ci.yml: check + test on Node 22/24/26 (ubuntu) and Node 24 on Windows and macOS, Codecov upload, package build + npm smoke on Node 22/24/26, JSR dry run. A release job runs semantic-release on main to publish to npm (OIDC trusted publishing, provenance) and JSR (OIDC); it is gated on the repository variable RELEASE_ENABLED == 'true', so merging does not publish yet.
  • README: installation for npm/pnpm/JSR, Node and browser usage, Hono example; Deno and Oak sections removed. PUBLISHING.md lists the one-time setup.

Verification

Run locally on Node 26.11.1 / pnpm 12.10.1 from a clean node_modules:

  • pnpm install --frozen-lockfile: passes
  • pnpm check (oxlint type-aware + type-check, oxfmt --check, tsc --noEmit): passes, no warnings
  • pnpm test:coverage: 120 tests pass; statements 100% (122/122), branches 100% (114/114), functions 100%, lines 100% (Deno baseline on main: branches 97.6%, functions 100%, lines 99.4%)
  • pnpm build: passes; dist/ has no node: imports
  • pnpm smoke: passes (and fails when dist is mutated)
  • pnpm jsr:dry-run (jsr publish --dry-run): passes, no slow-types errors, test files excluded
  • semantic-release --dry-run with only the analyzer plugins: next version 0.12.0

CI on this PR is green on Node 22/24/26 (ubuntu), Node 24 on Windows and macOS, the npm smoke on Node 22/24/26, the JSR dry run, and Codecov. Not verified: the release job (skipped until RELEASE_ENABLED is set) and actual npm/JSR publishing.

Founder setup steps (one time; details in PUBLISHING.md)

  1. JSR: confirm @udibo/http-error is linked to udibo/http-error in the package settings (OIDC publishing, no token).
  2. npm: the package does not exist yet, and npm cannot configure a trusted publisher for a package that does not exist. For the first release only, add a short-lived granular npm token for the @udibo scope as the repository secret NPM_TOKEN.
  3. Set the repository variable RELEASE_ENABLED=true.
  4. Squash-merge this PR with a feat: title; the release job publishes 0.12.0 to npm (with provenance) and JSR and tags it.
  5. In npm, add a Trusted Publisher for @udibo/http-error: organization udibo, repository http-error, workflow ci.yml, no environment.
  6. Delete the NPM_TOKEN secret and revoke the token.

Squash-merge with a feat: title (no !); the release rules treat breaking changes as minor releases while the version is 0.x, so 0.12.0 is the result either way.

🤖 Generated with Claude Code

KyleJune and others added 5 commits October 10, 2026 00:21
Deno is no longer a supported development runtime for this package, so the
Deno workspace config, lockfile, editor settings, publish workflow, and the
Oak example are removed ahead of the Node migration.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Build the package with tsc into ESM JavaScript and type declarations under
dist/ and publish it to npm as well as JSR (raw TypeScript). The source is
erasable-only TypeScript with isolated declarations, so JSR accepts it without
slow-type errors.

The @std/http/status dependency is replaced by a typed status table inlined in
src/status.ts, adapted from @std/http under its MIT license, so the package has
no runtime dependencies and imports no Node.js modules. The public API of
mod.ts is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Every behavioral assertion from the Deno suite is kept. Brittle assertions are
tightened: the default-name table is explicit instead of derived from the
status table, the response statusText assertion is unconditional, and the
invalid JSON test no longer matches V8's error message text. Added coverage for
the old error-name conversion, exposed message defaults, and the status table.

The Hono example exports its app and is exercised with app.request() instead of
a spawned server.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Run lint, formatting, type checks, and tests on Node 22, 24, and 26 on Linux
and on Node 24 on Windows and macOS, upload coverage to Codecov, and smoke-test
the packed npm tarball as a consumer would. Releases run semantic-release on
main to publish to npm (OIDC trusted publishing with provenance) and JSR, and
stay off until the RELEASE_ENABLED repository variable is true.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Remove the Deno and Oak instructions and run the Hono example on Node.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@KyleJune
KyleJune merged commit 90649e6 into main Oct 10, 2026
20 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 0.12.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant