Skip to content

Add WASM/async support via feature flag #599

@geofflittle

Description

@geofflittle

Hello! I'm working on a project that compiles to WASM and would love to use taskchampion as a library. Currently, this isn't possible due to a dependency that doesn't support the wasm32-unknown-unknown target.

This issue proposes a non-breaking change to add first-class support for using taskchampion in a WASM and async context.

The Problem
When attempting to compile taskchampion for a WASM target, the build fails:

  • UUID Generation: The uuid crate's default v4 feature relies on OS-level random number generation, which is not available in WASM.

Proposed Solution
I propose introducing a new wasm feature flag. When a user enables this feature and disables default features, the library will be fully WASM-compatible.

A consumer of the library would use it in their Cargo.toml like this:

[dependencies]
taskchampion = { version = "...", default-features = false, features = ["wasm"] }

This approach is fully backward-compatible and requires no changes for existing users.

Implementation Plan
I plan to submit a pull request with several small, logical commits to implement this. Each commit will represent a focused step in the process, making the changes easier to review.

  1. Add wasm feature and configure uuid
        * Add the new wasm = ["uuid/js"] feature to Cargo.toml.
        * This configures the uuid crate to use the browser's random number generator when the wasm feature is active.
  2. Introduce the AsyncServer trait
        * Add the async-trait dependency.
        * Define a new pub trait AsyncServer, mirroring the synchronous Server trait, to provide a clear interface for non-blocking server implementations.
  3. Implement async synchronization
        * Implement the core async logic in a new taskdb/async_sync.rs module.
        * Add the public-facing async fn sync_async(...) methods to Replica and TaskDb.

This will make taskchampion a much more versatile library and open it up to a new ecosystem of web and serverless applications. I'm happy to discuss this proposal and am open to any feedback.

Thank you!
-Geoff

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions