fix: rewrite CLI to use esbuild bundle output#480
Draft
garythebat wants to merge 3 commits intoGridSpace:rel-nextfrom
Draft
fix: rewrite CLI to use esbuild bundle output#480garythebat wants to merge 3 commits intoGridSpace:rel-nextfrom
garythebat wants to merge 3 commits intoGridSpace:rel-nextfrom
Conversation
Rewrites cli.js to use the pre-built kiri-eng.js and kiri-work.js bundles instead of the removed gapp.js eval-based loader. Same CLI interface (--model, --device, --process, --output, etc.), same in-process Worker bridge pattern, same single-threaded execution as the original. The bundles are consumed read-only as build output. Tested on ARM64 (Raspberry Pi 5) with cube.stl + Ender 3 FDM config.
- Call setMode() before setDevice()/setProcess() so mode defaults are set first, then overridden by custom configs - Rename local 'process' variable to 'procset' to avoid shadowing Node's global process object (breaks process.exit/stderr in ESM)
- Intercept fs.readFileSync to redirect wasm lookups to src/wasm/ so manifold-3d loads correctly (eliminates stderr WASM errors) - Set controller threaded:false after setMode to prevent mode switch from re-enabling the pool - Suppress manifold Aborted() exceptions cleanly - Document CAM limitation (needs worker pool, not yet wired) - FDM, LASER, SLA modes work in single-threaded mode
Author
|
Marking as draft — still completing tests before requesting review. Will mark ready once we've validated FDM/LASER/SLA outputs against a full test matrix. |
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.
Summary
Rewrites
src/kiri/run/cli.jsto use the pre-built esbuild bundles (kiri-eng.js+kiri-work.js) instead of the removedgapp.jseval-based loader. Same CLI interface, same in-process Worker bridge pattern, same single-threaded execution model as the original.Follows up on #478 and #479 (Docker + esbuild build fixes) which made the bundles reliable to produce. With those merged, the CLI can consume the bundles directly as read-only build output.
Commits
setMode()beforesetDevice()/setProcess()so mode defaults land first; rename localprocesstoprocsetto avoid shadowing Node's globalprocess(was silently breakingprocess.exit/stderrunder ESM)fs.readFileSyncto redirect.wasmlookups tosrc/wasm/somanifold-3dloads correctly; suppressAborted()exceptions cleanly from optional WASM modules; explicitly setcontroller.threaded:falseaftersetModeto prevent the mode switch from re-enabling the poolWhat works
--model,--device,--process,--output,--tools,--verbose).--verbose.What's explicitly deferred
CAM mode is documented at the top of
cli.jsas limited. The in-process Worker bridge short-circuits the parallel toolpath pool that CAM relies on. Wiring CAM up properly needs Node'sworker_threadsbehind the sameglobalThis.Workershim — meaningful scope best handled as a follow-up PR so this one stays reviewable.The CAM config templates (
src/cli/kiri-cam-{device,process,tools}.json) are kept in-tree so the follow-up can focus on just the worker pool.Testing
Run any of:
Or the LASER/SLA equivalents with matching device/process JSON. Works on Node 22 (Docker image and host).
Platform notes
npm run pack-prodafter install) — fix: add missing build steps and update Node in Dockerfile #478 ensures the Dockerfile does this automatically.