build: add --web pass-through for --target js (browser ES module) - #14
Merged
Conversation
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.
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.
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
--webmode (pyrex41/ShenScript#8) that drops the Node-isms (node:fs,streams.node.js, theprocess/Denoprobe, theprocess.exitmain) and instead boots the runtime, runs the shaken forms, andexport default $— so a page canimport $ from './app.js'; $.caller('parse-capture')(…). This exposes it from the ratatoskr CLI so PWAs don't have to invokebin/ratatoskr-build.jsby hand.How
--webis a bool flag onbuild/run, validated to apply only to--target js(errors otherwise).build(), which appends--webto the stage-2 step whose argv referencesratatoskr-build.js.paritypassesweb=false— deliberately kept build-only rather than a full target: a browser module runs its output throughconsole.log(line-oriented, trailing newline), so it isn't a clean stdout parity participant. Leavingparity/targetsuntouched avoids surprising those flows.reorderArgsalready handled bool flags; addedTestReorderArgsWebBoolFlagasserting--webis pulled forward without swallowingPROG/OUTDIR.Verified
go build/go vet/go test ./...all pass. End-to-end against a real PWA kernel (aparse-capture+ 7-view shake):--target js --webemits a browser-clean module (nonode:fs/streams/process), and the exported$renders every view with correcttoListTree/toArrayTreemarshalling.Pairs with pyrex41/ShenScript#8 (merged).