Skip to content

@deltic/translator: packaged asset + defaultTranslator() per-platform loader - #61

Merged
lann merged 1 commit into
mainfrom
translator-package
Aug 10, 2026
Merged

@deltic/translator: packaged asset + defaultTranslator() per-platform loader#61
lann merged 1 commit into
mainfrom
translator-package

Conversation

@lann

@lann lann commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

PR 4 of 4 from the #16 delivery design note (see the issue comment for the full decision record).

The package: translator/ (workspace member) owns the gitignored asset (copied by just shim) and defaultTranslator() — lazy, realm-cached, per-platform:

  • Deno: the wasm rides the static module graph permission-free — reached through a string-literal dynamic import (statically analyzable, still lazy, invisible to other platforms), wrapped by Translator.fromExports: the ESM wasm-import delivery path (runtime half) #60's Translator.fromExports. Empirical correction along the way: a computed import(url) is permission-gated in Deno; only the literal form joins the graph.
  • Node: node:fs read of the packaged asset.
  • Browser: fetch(new URL(…, import.meta.url)), the bundler-standard pattern.

Examples dogfood it: both hosts now run with --allow-read=build — the component read is the only permission left on the command line.

Separate package by design: build-time-translating consumers (#59's tools/translate, A4) deploy zero translator bytes; @deltic/runtime stays asset-free. Publish-time asset/digest pinning stays with #16's packaging work, as does JSR .wasm-asset verification.

Gates: test-translate (incl. package checks), examples, test-runtime, conformance 1254/0 (0 unexpected/stale), sched-seeds.

… loader

Item 3 of the #16 delivery design note (lands after fromExports, which
the Deno path consumes).

A separate package, deliberately: the translator is a versioned peer of
the runtime, but build-time-translating consumers (tools/translate, A4)
deploy no translator at all — keeping the 1.85 MB asset out of
@deltic/runtime keeps their production graphs clean.

defaultTranslator(): lazy, realm-cached. Platform arms:
- Deno: the wasm rides the STATIC module graph — mod.ts reaches the
  Deno-only asset module through a string-literal dynamic import, which
  Deno statically analyzes (permission-free) while keeping evaluation
  lazy and non-Deno platforms away from the wasm import. Empirical
  correction folded in: a COMPUTED import(url) is permission-gated in
  Deno — only the literal form rides the graph. Wrapped via
  Translator.fromExports (no compile, no copy).
- Node: node:fs readFile of the packaged asset (wasm-module imports are
  still experimental there).
- Browser/workers: fetch(new URL(..., import.meta.url)) — the
  bundler-standard asset pattern.

The asset is copied from the cargo build by `just shim` (gitignored);
publish tooling pins the exact asset + digest when #16 packaging lands.
A missing asset fails at defaultTranslator() call time with a
run-`just shim` hint.

Examples dogfood it: both hosts drop the shim readFile and the
../../target permission — `deno run --allow-read=build host.ts` is the
full command line, with the component read as the only permission left.

Tests (translator/tests, wired into the test-translate recipe):
defaultTranslator translates envelope-identically to a bytes-built
Translator; singleton identity per realm.

Gates: test-translate (incl. the new package checks), examples,
test-runtime, conformance (1254/0, 0 unexpected, 0 stale), sched-seeds.
@lann
lann enabled auto-merge August 10, 2026 22:30
@lann
lann merged commit 9dc7141 into main Aug 10, 2026
4 checks passed
@lannbot
lannbot deleted the translator-package branch August 23, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant