Repository navigation
Build service documentation as a reusable crate and WebAssembly module - #230
Merged
Merged
Conversation
tnkuehne
force-pushed
the
feat/service-docs-wasm
branch
from
November 19, 2026 17:24
499d1d8 to
40ab0a0
Compare
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
widefleet-docs | d0cdca9 | Nov 19 2026, 11:38 PM |
tnkuehne
force-pushed
the
feat/service-docs-wasm
branch
from
November 19, 2026 17:56
f287c2b to
dbb661b
Compare
Move the CLI's service documentation extraction into platform-service-docs with an injected file system, so the same implementation runs natively in the CLI and as a wasm32-wasip1 module (platform-service-docs-wasm) over a host file system. An entry mode checks the original entry module instead of the bundle, which keeps the type-checking program small enough for a Worker isolate.
Entry mode now follows identifiers to their declarations, so `export default (handler satisfies Handler)` is documented, and keeps the app's own declaration files from tsconfig, such as global interfaces. A shared fixture checks native and WebAssembly output against one expected result. The new @platform/service-docs package runs the module over an in-memory file system; CI runs it after building the module. The new crate is a CLI release input.
The app builder typechecks it with @cloudflare/workers-types.
tnkuehne
force-pushed
the
feat/service-docs-wasm
branch
from
November 19, 2026 23:37
dbb661b to
d0cdca9
Compare
tnkuehne
added a commit
that referenced
this pull request
Nov 20, 2026
`@platform/app-builder` turns an app project's source files into what `widefleet deploy` uploads: the bundled `worker.js`, its source map, the Worker metadata and the service documentation. It is the build service for one-click template installs and runs in workerd and celld. - `POST /bundle` installs the project's npm dependencies with `@cloudflare/worker-bundler`, bundles the Wrangler entry like the CLI and returns the module, source map and metadata (bindings, compatibility flags, crons, queue consumers, entrypoints, build ID). - `POST /document` installs the declarations of the dependencies and of the development dependencies the sources or tsconfig reference, runs the service documentation module from #230 in entry mode and returns any declaration install warnings. The two phases are separate requests, so a hosted installation can deploy the Worker twice and keep their memory in separate isolates. Only the control plane reaches the builder, through service bindings or a private network that no other workload joins. `NPM_REGISTRY` selects a registry such as a company mirror. Syntax errors and imports that do not resolve are reported as build errors, as the CLI's bundler reports them; the source map module is named by its digest, as the CLI names it, so the build ID covers the map. Projects with static assets keep deploying through the CLI. For the Gmail, GitHub and OneDrive templates the builder's module and source map positions are byte-identical across workerd and celld, and the documentation is identical to the CLI's. Remaining bundle differences come from dependency versions installed from npm. Source maps contain positions only: the control plane maps stack traces by position, and documentation reads the original files. The pinned `@cloudflare/[email protected]` patch: - resolves packages with the bundle's export conditions and browser fields, which selects the `workerd` builds of `@better-auth/core` and `@better-auth/utils` as esbuild does for the CLI; - matches externals exactly, so `fs` does not externalize `fs-extra`; - streams package archives, unpacks at most three at once and keeps only the files each phase reads, including empty modules; - forwards `sourcesContent` and stops esbuild between builds, whose heap otherwise keeps its largest size. On Cloudflare a full Gmail build kept 56 MiB below the isolate memory limit, and six consecutive builds succeeded; with the unpatched bundler a single build exceeded it. Builds take 3–7 seconds in celld. Stacked on #230. Later changes deploy the builder for hosted and self-hosted installations and add template installs to the control plane, API and CLI. Validation: `pnpm check`; `RUN_BUILDER_TESTS=1` runs the built Worker in Miniflare against a synthetic npm registry. It covers CLI-equivalent metadata, the `workerd` export condition, empty modules and code named like documentation, the `require` bridge and source map offset, the build ID, documentation including type-only development dependencies, and project and source errors. The main test fails with the unpatched bundler. CI builds the documentation module and the Worker before these tests. <!-- greptile_comment --> <!-- greptile_summary --> <h2><a href="https://app.greptile.com/api/retrigger?id=113052135&sig=539e63bc66cd3e73b79b3ef5e4c3a19b8c60ef795adac929748b90ade0552214"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img alt="Retrigger" src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2" align="right"></picture></a><a href="https://app.greptile.com/-/switch-tenant?tenant=mendra&next=%2Fwidefleet%2Fwidefleet%2Fpull%2F232&utm_source=greptile_review&utm_medium=github&utm_campaign=view_in_greptile"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img alt="View in Greptile" src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2" align="right"></picture></a>Confidence Score: 5/5</h2> <!-- greptile-impact-verdict --> The follow-up appears safe to merge; no new blocking issues were found. <details open><summary><h3>Summary</h3></summary> Adds a server-side Worker that builds app source files and generates service documentation in separate requests. - The builder turns Wrangler projects into deploy-ready Worker bundles. - The builder creates service docs from project files and type declarations. - Package downloads and bundling use less memory per build. tnkuehne accepts leaving unresolved `require()` calls for runtime so optional dependencies inside `try` blocks can build. </details> <!-- greptile_confidence_score:5 --> <sub>Reviews (8) · Last reviewed commit: ["Leave unresolved require() calls for run..."](1a5282c) · [Reviewed by Greptile](https://www.greptile.com/?utm_source=greptile_review&utm_medium=github&utm_campaign=review_public&utm_content=widefleet/widefleet)</sub> <!-- /greptile_comment -->
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.
Service documentation extraction moves from the CLI into
platform-service-docs, so a server-side build can produce the sameservice_documentationaswidefleet deploy. The library takes the file system as a parameter: the CLI passes the operating system's, and the newplatform-service-docs-wasmcrate passes a host file system when built forwasm32-wasip1. The module uses tsrs's WebAssembly ABI and host protocol, so tsrs's JavaScript host runs it unchanged.An entry mode checks the original entry module instead of the bundle. The bundle mode remains the CLI's behavior; it maps bundled exports back through the source map and therefore also supports generated entry modules. Entry mode documents only declarations from the app's own sources, as the bundle mode recovers only those. For the Gmail, GitHub and OneDrive templates both modes produce byte-identical documentation, natively and in WebAssembly; the entry mode's program needs 75 MiB of linear memory instead of 113 MiB because it excludes the bundled dependencies.
The
wasmCargo profile builds the module at 10.6 MB with tsrs's size settings. CI installs the target fromrust-toolchain.toml, lints the crate forwasm32-wasip1and builds the module in the Rust suite.This is the first part of one-click template installs: a later change runs this module next to
@cloudflare/worker-bundlerto document template APIs during a server-side build.Validation:
cargo fmt --check,cargo clippy --workspace --all-targets -D warnings, the WebAssembly clippy and build,cargo test --workspace, andRUN_CLI_TESTS=1forservice-documentation.test.tsandapp-services-cli.test.ts(52 tests) pass. New tests cover entry-mode documentation and skipping services declared by dependencies.

Confidence Score: 5/5
The PR appears safe to merge; no blocking issues were found.Summary
Service documentation moves into a shared Rust library that both the CLI and a new WebAssembly module can use.
The four earlier concerns are addressed: wrapped handlers resolve correctly, configured app declaration files remain included, library edits trigger CLI releases, and CI runs the built module. No new actionable issues were found.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR CLI[CLI deploy] --> Adapter[CLI extraction adapter] Adapter --> Library[Shared documentation library] Adapter --> OS[Operating system files] JS[JavaScript documentServices] --> WASM[WebAssembly module] WASM --> Library WASM --> Host[Host file calls] Host --> Files[In-memory files] Library --> JSON[Service documentation JSON]Reviews (6) · Last reviewed commit: "Match the service documentation crates t..." · Reviewed by Greptile