From 3516bd69f4aaf5be401d3e03cb45d2e5bbc28638 Mon Sep 17 00:00:00 2001 From: Maze Winther Date: Wed, 1 Apr 2026 21:30:26 +0200 Subject: [PATCH] fix: use published opencut-wasm package --- .github/CONTRIBUTING.md | 5 ++--- README.md | 37 +++++++++++++++++++++++++++++++++++++ apps/web/package.json | 2 +- bun.lock | 8 ++------ package.json | 3 +-- rust/wasm/README.md | 21 +++++++++++++++++++++ 6 files changed, 64 insertions(+), 12 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 8167b6e2..f251603f 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -45,10 +45,9 @@ Thank you for your interest in contributing to OpenCut! This document provides g 5. Install dependencies: `bun install` 6. Start the development server: `bun run dev` -> **Note:** If you see an error like `Unsupported URL Type "workspace:*"` when running `npm install`, you have two options: +> **Note:** Web development uses the published `opencut-wasm` package by default, so a fresh clone does not need a local WASM build. > -> 1. Upgrade to a recent npm version (v9 or later), which has full workspace protocol support. -> 2. Use an alternative package manager such as **bun** or **pnpm**. +> If you are editing `rust/wasm`, run `bun run build:wasm`, then `cd rust/wasm/pkg && bun link`, then `cd ../../../apps/web && bun link opencut-wasm`. ### Desktop setup diff --git a/README.md b/README.md index 493e2277..a6594094 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,43 @@ Desktop is opt-in. If you're only working on the web app, skip this entirely. If you want to get ready for `apps/desktop`, see [`apps/desktop/README.md`](apps/desktop/README.md). It's a two-step setup: Rust toolchain first, then desktop native dependencies. +### Local WASM development + +Only needed if you're editing `rust/wasm` and want the web app to use your local build instead of the published package. + +1. Build the package once from the repo root: + + ```bash + bun run build:wasm + ``` + +2. Register the generated package for linking: + + ```bash + cd rust/wasm/pkg + bun link + ``` + +3. Link `apps/web` to the local package: + + ```bash + cd apps/web + bun link opencut-wasm + ``` + +4. Rebuild on changes while you work: + + ```bash + bun dev:wasm + ``` + +To switch `apps/web` back to the published package, run: + +```bash +cd apps/web +bun add opencut-wasm +``` + ### Self-Hosting with Docker To run everything (including a production build of the app) in Docker: diff --git a/apps/web/package.json b/apps/web/package.json index c7d55572..f765216c 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -22,7 +22,6 @@ "@hugeicons/core-free-icons": "^3.1.1", "@hugeicons/react": "^1.1.6", "@huggingface/transformers": "^3.8.1", - "opencut-wasm": "workspace:*", "@opennextjs/cloudflare": "^1.18.0", "@radix-ui/react-accordion": "^1.2.12", "@radix-ui/react-checkbox": "^1.3.3", @@ -53,6 +52,7 @@ "nanoid": "^5.1.5", "next": "16.1.3", "next-themes": "^0.4.4", + "opencut-wasm": "^0.1.2", "pg": "^8.16.2", "postgres": "^3.4.5", "radix-ui": "^1.4.3", diff --git a/bun.lock b/bun.lock index bc1dff3b..ef674788 100644 --- a/bun.lock +++ b/bun.lock @@ -54,7 +54,7 @@ "nanoid": "^5.1.5", "next": "16.1.3", "next-themes": "^0.4.4", - "opencut-wasm": "workspace:*", + "opencut-wasm": "^0.1.2", "pg": "^8.16.2", "postgres": "^3.4.5", "radix-ui": "^1.4.3", @@ -102,10 +102,6 @@ "wrangler": "^4.77.0", }, }, - "rust/wasm/pkg": { - "name": "opencut-wasm", - "version": "0.1.2", - }, }, "trustedDependencies": [ "@tailwindcss/oxide", @@ -1363,7 +1359,7 @@ "onnxruntime-web": ["onnxruntime-web@1.22.0-dev.20250409-89f8206ba4", "", { "dependencies": { "flatbuffers": "^25.1.24", "guid-typescript": "^1.0.9", "long": "^5.2.3", "onnxruntime-common": "1.22.0-dev.20250409-89f8206ba4", "platform": "^1.3.6", "protobufjs": "^7.2.4" } }, "sha512-0uS76OPgH0hWCPrFKlL8kYVV7ckM7t/36HfbgoFw6Nd0CZVVbQC4PkrR8mBX8LtNUFZO25IQBqV2Hx2ho3FlbQ=="], - "opencut-wasm": ["opencut-wasm@workspace:rust/wasm/pkg"], + "opencut-wasm": ["opencut-wasm@0.1.2", "", {}, "sha512-3OZ7JYwFNFijqQIFBgrqzyD+0V5yG4KPJtRPR76UcqM3Ai3y2GXdp7IlDL7NG3IoQ4C5yX2LzKl2pr4FbDvuFQ=="], "p-limit": ["p-limit@6.2.0", "", { "dependencies": { "yocto-queue": "^1.1.1" } }, "sha512-kuUqqHNUqoIWp/c467RI4X6mmyuojY5jGutNU0wVTmEOOfcuwLqyMVoAi9MKi2Ak+5i9+nhmrK4ufZE8069kHA=="], diff --git a/package.json b/package.json index c357e99a..2b77a0d3 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,7 @@ "packageManager": "bun@1.2.18", "workspaces": [ "apps/*", - "packages/*", - "rust/wasm/pkg" + "packages/*" ], "scripts": { "build:tools": "turbo run build --filter=@opencut/tools", diff --git a/rust/wasm/README.md b/rust/wasm/README.md index bb6f62e7..e90c58c2 100644 --- a/rust/wasm/README.md +++ b/rust/wasm/README.md @@ -19,3 +19,24 @@ All exports are documented in the [TypeScript definitions](./opencut_wasm.d.ts). ## Source Functions are implemented in Rust under [`rust/crates/`](../crates/). This package is the compiled WebAssembly output — do not edit it directly. + +## Local development + +The web app depends on the published `opencut-wasm` package by default. If you are editing the WASM source in this repo and want `apps/web` to use your local build instead: + +```bash +# From the repo root +bun run build:wasm + +cd rust/wasm/pkg +bun link + +cd ../../../apps/web +bun link opencut-wasm +``` + +While you work, rebuild on changes from the repo root: + +```bash +bun dev:wasm +```