WDK logoWDK documentation

Worklet Bundler

CLI tool for generating WDK Bare worklet bundles

Worklet Bundler packages selected WDK wallet, protocol, and optional generic modules into a Bare runtime bundle that runs outside the host application thread. It can generate the default HRPC worklet used by React Native Core or a framed JSON-RPC bundle for a native host. Powered by @tetherto/wdk-worklet-bundler.

Features

  • Config-driven bundle generation: Map logical network names to wallet packages, protocol names to protocol packages, and HRPC-only generic-module names to package factories.
  • HRPC and JSON-RPC transports: Generate an HRPC JavaScript bundle by default or a length-prefixed JSON-RPC bundle for native hosts.
  • Generated worklet artifacts: Produce a Bare bundle, a stable ./.wdk host import, and generated TypeScript types.
  • Native addon outputs: Link iOS, macOS, and Android addons and generate addons.yml for JSON-RPC/native integrations.
  • Dependency validation helpers: Validate configured modules, detect the active package manager, and generate install or uninstall commands when dependencies are missing.
  • Dynamic-call allowlists: Restrict generated wallet and protocol callMethod() surfaces for HRPC and JSON-RPC, plus generic-module callModule() surfaces for HRPC.
  • Optional peer deferral: Defer missing peers marked optional by their package metadata, or require them at build time with --no-defer-optional-peers.
  • Explicit ESM-to-CJS conversion: Opt in for JSC, QuickJS, or another CommonJS-only Bare engine, with a matching runtime loader patch and post-conversion bundle validation.
  • CLI workflow: Use init, validate, generate, list-modules, and clean without building your own wrapper.
  • Bare lifecycle handling: Generated HRPC entrypoints suspend and resume both the bare-http1 and bare-https global agents and log Bare suspend, resume, and idle events.

v1.0.0-beta.10 makes ESM-to-CJS conversion explicit and transport-independent. When enabled in wdk.config.js, the generated entrypoint installs the matching .mjs CommonJS loader patch and the build validates the rewritten raw or default UTF-8-wrapped bundle before succeeding. The release also exports convertBundleEsmToCjs() and validateBundle() for programmatic workflows.

Why this matters

  • Bundle generation keeps wallet and protocol code in a separate Bare worklet instead of the UI thread.
  • The generated type output gives the host app a stable import for the bundle surface.
  • Transport-specific defaults produce a JavaScript HRPC bundle for React Native Core or native addon artifacts for JSON-RPC hosts; JavaScript-engine compatibility is configured separately.

Generic modules are generated only for HRPC through beta.10. A JSON-RPC config can currently accept a modules field but silently omits those modules from the generated entrypoint.


Need Help?

On this page