@deltic/translator: packaged asset + defaultTranslator() per-platform loader - #61
Merged
Conversation
… 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.
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.
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 byjust shim) anddefaultTranslator()— lazy, realm-cached, per-platform:Translator.fromExports. Empirical correction along the way: a computedimport(url)is permission-gated in Deno; only the literal form joins the graph.node:fsread of the packaged asset.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/runtimestays 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.