Build JS bridge from source#15
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a JavaScript build pipeline for the WebGPU bridge so editable bridge sources live under js/src/ while checked-in browser assets remain under js/ for downstream/CDN compatibility.
Changes:
- Adds npm/esbuild/TypeScript tooling and generated JS/DTS bridge assets.
- Updates CI, publish, and native build scripts to validate and ship generated bridge outputs.
- Updates docs and static verification scripts for the new JS build workflow.
Reviewed changes
Copilot reviewed 13 out of 19 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
.github/workflows/ci.yml |
Adds Node setup and JS bridge validation to CI. |
.github/workflows/publish_assets.yml |
Validates JS assets and publishes the new declaration file. |
.gitignore |
Ignores local npm dependencies. |
AGENTS.md |
Updates agent validation guidance for the JS build gate. |
CONTRIBUTING.md |
Documents JS build prerequisites and validation commands. |
README.md |
Documents source/generated bridge layout, build steps, and CDN assets. |
package.json |
Defines JS build, typecheck, syntax-check scripts and dev dependencies. |
package-lock.json |
Locks JS build tooling dependencies. |
tsconfig.bridge.json |
Adds TypeScript checkJs configuration for bridge source. |
scripts/build_js_bridge.mjs |
Generates bundled bridge assets and copies declarations. |
scripts/build_bridge.sh |
Runs JS validation and copies .d.ts into dist. |
scripts/verify_ci_reliability.py |
Extends static workflow/build contract checks for JS assets. |
scripts/verify_state_persistence_api.py |
Points state-persistence checks at bridge source. |
js/src/llama_webgpu_bridge.js |
Adds editable bridge runtime source. |
js/src/llama_webgpu_bridge.d.ts |
Adds editable public declaration source. |
js/src/llama_webgpu_bridge_worker.js |
Adds editable worker entry source. |
js/llama_webgpu_bridge.js |
Generated browser ESM bridge bundle. |
js/llama_webgpu_bridge.d.ts |
Generated public declaration asset. |
js/llama_webgpu_bridge_worker.js |
Generated worker entry asset. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Closes #14.
js/src/and generate checked-in browser assets underjs/.npm run check:js) that type-checks source, regenerates readable ESM outputs, copies declarations, and syntax-checks generated files.Deep review cleanups included
BigInt(...)initialization for streamed FS writes so non-BigInt paths keep prior behavior..d.tscoverage for real config keys, token callback semantics, state load return types, andsupportsSafariAdaptiveGpu.build_bridge.shusenpm ci --include=dev --ignore-scriptswhen bootstrapping.build_bridge.shauto-installs JS dependencies.Validation
npm run check:jsnpm ci --include=dev --ignore-scripts --dry-runpython3 -m py_compile scripts/verify_state_persistence_api.py scripts/verify_ci_reliability.py scripts/state_persistence_browser_smoke.pypython3 scripts/verify_state_persistence_api.pypython3 scripts/verify_ci_reliability.py./scripts/build_bridge.sh --helpsmokegit diff --checkReview follow-up
Addressed Copilot's comments in
cd95f70:coreModuleFactory, including promised factories.cmakebeforebuild_bridge.shcan auto-install JS dependencies.js/src/**/*.d.tsin the TypeScript validation gate so declaration syntax/types are parsed before publishing.Downstream llamadart validation
Validated the successful PR artifact from CI run
25941537878against/opt/UnitySrc/personal/llama/llamadart:webgpu-bridge-distfor headcd95f7053264e7f17b0dce8592e45e4fe0b37c9fand verified it contains bridge JS, worker JS,.d.ts, wasm32, and wasm64 assets.tool/testing/playwright_bridge_smoke.pyagainst the PR artifact JS served under/webgpu_bridge/.dart analyze lib/src/backends/webgpu test/integration/backends/webgpu.dart test -p chrome test/integration/backends/webgpu/webgpu_engine_multimodal_browser_integration_test.dart.llamadart/example/chat_app/web/webgpu_bridge/, built the Flutter web chat app withflutter build web --base-href=/example/chat_app/build/web/, and rantool/testing/playwright_chat_app_real_model_smoke.pyagainst Qwen3.5-0.8B-Q4_K_M GGUF; observed response:2+2 equals 4.Local
llamadartbridge assets were restored after the smoke; no downstream repo changes were left behind.Notes
always-authdeprecation warnings from user npm config; the commands still pass.