Skip to content

build: add --web pass-through for --target js (browser ES module) - #14

Merged
pyrex41 merged 1 commit into
mainfrom
feat/web-passthrough
Jul 24, 2026
Merged

build: add --web pass-through for --target js (browser ES module)#14
pyrex41 merged 1 commit into
mainfrom
feat/web-passthrough

Conversation

@pyrex41

@pyrex41 pyrex41 commented Jul 24, 2026

Copy link
Copy Markdown
Owner

What

ratatoskr build prog.shen out/ --target js --web — emit a browser-safe ES module from a shake, instead of the default Node artifact.

Why

ShenScript's stage-2 builder just gained a --web mode (pyrex41/ShenScript#8) that drops the Node-isms (node:fs, streams.node.js, the process/Deno probe, the process.exit main) and instead boots the runtime, runs the shaken forms, and export default $ — so a page can import $ from './app.js'; $.caller('parse-capture')(…). This exposes it from the ratatoskr CLI so PWAs don't have to invoke bin/ratatoskr-build.js by hand.

How

  • --web is a bool flag on build/run, validated to apply only to --target js (errors otherwise).
  • Threaded into build(), which appends --web to the stage-2 step whose argv references ratatoskr-build.js.
  • parity passes web=false — deliberately kept build-only rather than a full target: a browser module runs its output through console.log (line-oriented, trailing newline), so it isn't a clean stdout parity participant. Leaving parity/targets untouched avoids surprising those flows.
  • reorderArgs already handled bool flags; added TestReorderArgsWebBoolFlag asserting --web is pulled forward without swallowing PROG/OUTDIR.
  • README + top-of-file usage documented.

Verified

go build / go vet / go test ./... all pass. End-to-end against a real PWA kernel (a parse-capture + 7-view shake): --target js --web emits a browser-clean module (no node:fs/streams/process), and the exported $ renders every view with correct toListTree/toArrayTree marshalling.

Pairs with pyrex41/ShenScript#8 (merged).

ShenScript's stage-2 builder gained a --web mode that emits a browser-safe ES
module (no node:fs/streams/process; boots + exports the env for
`import $ from './app.js'; $.caller('fn')(...)`). Surface it from the CLI:
`ratatoskr build prog.shen out/ --target js --web` appends --web to the
ShenScript builder step.

- --web is a bool flag on build/run; validated to apply only to --target js.
- Threaded into build(); parity passes web=false (unaffected — a console.log-
  based browser module isn't a clean stdout parity participant, so --web stays
  build-only rather than a full target).
- reorderArgs already handles bool flags; added a test that --web is pulled
  forward without swallowing the PROG/OUTDIR positionals.
- README + usage documented.

Verified end-to-end: `--target js --web` on a real PWA kernel (parse + 7 views)
emits a browser-clean module (no node built-ins) whose exported $ renders every
view with correct JS<->Shen marshalling.
@pyrex41
pyrex41 merged commit 56d67c7 into main Jul 24, 2026
6 checks passed
@pyrex41
pyrex41 deleted the feat/web-passthrough branch July 24, 2026 03:36
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