Add Node and Bun support to the TypeScript client#217
Open
just-be-dev wants to merge 3 commits into
Open
Conversation
Rework the Deno client into a cross-runtime TypeScript client that works on Node (>= 20.9), Deno, and Bun, published to both JSR (@justbe/webview) and npm (@just-be/webview). - Rename src/clients/deno -> src/clients/typescript - Replace Deno.* APIs with node: builtins (child_process, fs, path, events); the only runtime-conditional code is a small getEnv shim that preserves Deno's permission-guard behavior - Drop the JSR-only @bcheidemann/tracing dep and @Instrument decorators in favor of a minimal internal logger honoring LOG_LEVEL - Add npm packaging (package.json, tsdown build, tsconfig.npm.json) and a version-gated npm publish workflow - Rename :deno mise tasks to :ts, add example:node and example:bun tasks - Keep deno.json name/version/exports unchanged so JSR consumers are unaffected Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
So, I've wanted to use this project outside of the deno ecosystem for a bit and it's high time to land a change to support both node and bun. Honestly, there's not really much of a dependency on deno to begin with. From a runtime perspective it's nice to have URL dependencies in a webview script but it's certainly not required. I'm not using FFI in this project at all given the binary approach (which I'm generally happy with). So, yeah. I still need to do the manual publishing of the package to NPM and setup the OIDC publishing step.
AI Summary
Reworks the Deno client into a cross-runtime TypeScript client that works on Node (>= 20.9), Deno, and Bun, published to both JSR (
@justbe/webview, unchanged) and npm (@just-be/webview, new). Existing Deno/JSR consumers are unaffected — same package name, version, exports, and permission behavior.Client changes (
src/clients/deno/→src/clients/typescript/)main.tsusesnode:builtins everywhere (child_process,fs/promises,path,events), which all three runtimes support natively. Web streams became Node streams, with a persistent streamingTextDecoder(also fixes a latent bug where multi-byte UTF-8 chars split across chunks would corrupt).runtime.tsholds the only runtime-conditional code:getEnv()preserves Deno's permission-guard behavior (no prompt without--allow-env), plusplatformOs()/platformArch()normalizers.logger.tsreplaces@bcheidemann/tracing+@instrument()decorators — that dep is JSR-only (npm packages can't depend on JSR-scoped packages), and TC39 decorators can't run on Node from raw TS. SameLOG_LEVELenv contract; per-method span traces are gone.Packaging & CI
package.json/tsdownbuild /tsconfig.npm.jsonfor the npm artifact (ESM + d.ts). The tsconfig is deliberately not namedtsconfig.json— Deno 2.4 picks that up and it breaksdeno check.deno.jsonsetsnodeModulesDir: "none"so Deno and npm don't fight overnode_modules.publish-deno.yml→publish-typescript-jsr.yml(logic unchanged, incl.deno-v*tags); newpublish-typescript-npm.ymlmirrors the version-gated pattern and publishes with--provenance.:denotasks renamed to:ts; newexample:node,example:bun,verify-publish:npm,lint:ts-npmtasks; node + bun added to tools.import { z } from "zod"(bare specifier);sync-versions.tskeepspackage.jsonversion locked todeno.json.Verification
deno lint,deno check,deno publish --dry-run, live smoke test (spawn → setTitle/getTitle round-trip → dispose) ✅tsctypecheck,tsdownbuild, live smoke via tsx, tarball installed in a scratch project with zero registry config ✅mise run lint,npm packcontents, codegen idempotency ✅Before npm publishing works
NPM_TOKENrepo secret with publish rights to the@just-bescope.@just-be/webviewpublish may need to be done manually to claim the name.🤖 Generated with Claude Code