Skip to content

Commit 25013bf

Browse files
miccysteidacoderabbitai[bot]CopilotCopilot
authored
PR: Migration common-v8 to biome and bun (#5)
* feat: Migrate project from pnpm/npm and ESLint/Prettier to Bun and Biome. * chore: Migrate project from pnpm/Node.js to Bun, update CI/CD workflows, Dockerfiles, and remove ESLint plugin and Prettier scripts. * feat: Enhance local-first synchronization, update SQLite drivers, and improve web app and examples. * feat: enhance type safety and consistency across tasks, collections, and component props, and temporarily disable ES2025 iterator tests and `useSyncState` export. * feat: Upgrade React to 19.1.0, simplify `Task` types, update `@types` and other dependencies, and switch docs script to Bun. * refactor: Update TypeScript configurations, refine `Task` types, and standardize `ok(undefined)` returns. * refactor: Configure TypeScript path aliases for improved module resolution and update target to ESNext. * refactor: Simplify TypeScript module resolution, refine `MainTask` type, and update bundle size expectations. * Remove redundant comment about retry behavior * Update .ai/tasks/active/finalize-bun-migration.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Miccy <code@miccy.dev> * Update packages/svelte/svelte-types.d.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Miccy <code@miccy.dev> * Add shutdown-aware createRunner; rename relay API Replace the old runMain pattern with a shutdown-aware createRunner that injects a shutdown promise into deps and installs global signal and error handlers (SIGINT, SIGTERM, SIGHUP, uncaughtException, unhandledRejection). Move Node.js runner wiring into packages/nodejs/src/Task.ts, resolve shutdown via process signals, and ensure listeners are cleaned up on runner dispose. Rename relay APIs: createNodeJsRelayBetterSqliteDeps -> createRelayDeps and createNodeJsRelay -> startRelay, update examples and the apps/relay entry to use startRelay and createRunner. Simplify task typing in packages/common (introduce AnyTask and use it in InferTask* helpers, add CreateRunner type, remove MainTask), and adjust the local-first Relay implementation to handle sqlite errors by logging and returning ok(stack). Update tests to reflect the new createRunner/shutdown behavior and to verify signal/error handling and listener cleanup. README updated to reflect the API rename. * Update pnpm-lock.yaml * Add browser Task runner with global error handling Introduce a browser-specific Task runner and tests. Implements createRunner in packages/web/src/Task.ts that composes the common runner, creates a console child named "global", registers global "error" and "unhandledrejection" handlers (logging via createUnknownError), and removes those listeners when the runner is disposed. Adds vitest tests in packages/web/test/Task.test.ts to verify custom deps merging, mocked listener registration/removal, real-event logging for ErrorEvent and PromiseRejectionEvent, and that handlers are detached after disposal. * Remove re-export of @evolu/web from react-web * Update packages/common/src/Types.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Miccy <code@miccy.dev> * Update packages/common/src/Task.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Miccy <code@miccy.dev> * Update apps/web/src/components/Header.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Miccy <code@miccy.dev> * Update packages/common/src/Task.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Miccy <code@miccy.dev> * Update packages/common/src/Task.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Miccy <code@miccy.dev> * Refactor abort handling in Task and update sizes * fix: Address type compatibility issues, migrate build scripts to Bun, and enhance Biome configuration and linting rules. * feat: Initialize Evolu Plan B fork, migrating project to Bun and updating metadata. * docs: Clarify full Bun and Biome implementation status in the README. * Remove Feature.id and use name as key * fix: workfows specific bun version * fix: usage specific Commit SHA for CI * feat: Streamline Docker build for relay app with Bun and update Vite plugin dependencies. * docs: Reorganize credits and license sections and add a new footer to README. * ci: configure triggers for PRs and main branch only * chore: enable biome for markdown and update vscode settings * ci: disable pull_request and issue_comment triggers for socket workflow. * ci: replace blocked setup-bun action with manual install script * refactor: update Socket Security workflow to manual dispatch with optional PR input and ensure proper Node.js task resource disposal. * fix(nodejs): fix syntax error causing ci failure * chore: fix Biome linting errors and formatting to resolve CI issues * fix(ci): set tsconfig target to es2022 to resolve await using syntax error * fix(ci): polyfill WebSocket in nodejs tests to resolve runtime TypeError * Remove Node.js WebSocket polyfill setup and update common package bundle size snapshot. * style: Add Biome ignore comments to suppress linting warnings and adjust `process.env` access. * feat: Add `format` script and update `verify` script to include formatting and remove `build:docs`. * fix: Use bracket notation for `process.env` access to avoid Vite define plugin issues and add biome lint ignore. * Initial plan * Add WebSocket polyfill for Node.js tests Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> * Replace Promise.withResolvers with compatibility helper Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> * Add Promise.try polyfill for Node.js tests Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> * Fix Promise.try polyfill error handling and type signature Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> * Fix TypeScript error: change @ts-expect-error to @ts-ignore Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> * Add polyfills for common package Node.js tests Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> * Fix polyfill initialization order and add missing polyfills Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> * Initial plan * Stabilize common package tests on CI Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> * refactor: Update polyfill assignments to use `as any` and refine `Promise.try` implementation. * chore: Update dependencies and fix Biome linting errors, including React Hooks rules. * chore: Update React to 19.2.4, motion to 12.30.0, turbo to 2.8.2, and other related dependencies. * feat: Add manual trigger to CI workflow and standardize Bun setup across CI and release workflows. * ci: Update GitHub Actions `checkout` to `v4` and `setup-bun` to `v2` across all workflows. * chore: Add Dependabot for GitHub Actions and pin workflow action versions in CI, release, and web-build workflows. * Enable React strict mode in Next.js config * chore: Update `oven-sh/setup-bun` GitHub Action to a newer commit hash across all CI/CD workflows. * Update browserslist and add @evolu/web dependency * Update pnpm-lock.yaml * Rename TaskDisposableStack to AsyncDisposableStack * Fix lint-monorepo * chore: update various dependencies including React Navigation, Framer Motion, and Node types. * fix: ci.yml SHA * Initial plan * fix: Add build:docs to verify script to fix ENOENT test errors Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> * fix: Remove build:docs and typedoc test from verify script Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> * fix: Increase timeout for flaky Protocol test Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> * docs: Add comment explaining timeout increase for E2E sync test Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> * Refactor Console docs and expand examples * Initial plan * Address PR review comments: fix types, hooks, and Dockerfile security Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> * Use default time dep in console formatter * Limit published files to dist/src and src Update packages/nodejs/package.json to change the "files" entry from "dist/**" to "dist/src/**". This restricts what gets packaged/published (avoiding unrelated files under dist), reducing package size and ensuring only the compiled source artifacts and src are included. * Remove createTime usage in console formatter Consolidate imports and stop passing a custom time provider to createConsoleEntryFormatter in apps/relay/src/index.ts. The createTime import and its usage were removed so the formatter uses its default time handling, and the import statement was simplified. * Add React Native runner and ErrorUtils handling * Bump several package versions in pnpm-lock Update pnpm-lock.yaml to refresh multiple dependency versions and integrity hashes. Notable bumps: @algolia/autocomplete-core/plugin/shared 1.19.4 -> 1.19.5, framer-motion & motion 12.30.1 -> 12.31.0, enhanced-resolve 5.18.4 -> 5.19.0, and dotenv 16.4.7 -> 16.6.1. Snapshots/resolutions updated accordingly — this is an automated lockfile refresh to keep transitive deps in sync. * feat: finalize merge before testing * refactor: move task runner logic to common package and simplify Node.js implementation. * fix: bun verify issues solved * Initial plan * Refactor TreeShaking test to avoid type-unsafe cast Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> * Add comprehensive code review summary document Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> * Initial plan * Reorder package exports and add default entries * Use workspace deps in examples Adapted from upstream e57edbe to use workspace:* for @evolu/* packages. Used explicit React versions (^19.2.3) instead of catalog:react19 since Bun doesn't support pnpm catalogs. Skipped pnpm-lock.yaml as we use bun.lockb. * Adjust tests to use mocked listeners and console * Cherry-pick 3 new upstream commits from common-v8 Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> * Add bun.lock with updated dependencies Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> * Fix React version consistency across monorepo to 19.2.4 Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> * Initial plan * fix: Increase timeout for Protocol E2E sync tests The "client and relay have all data" test was timing out with the default 5000ms timeout. This commit adds 15000ms timeouts to this test and other "many steps" tests in the E2E sync suite, following the pattern established in commit 0a8f3ea. Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> * Initial plan * fix: Eliminate race condition in Time.test.ts timing assertions Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> * Initial plan * fix: Change pool function return type from Task<any, any, any> to Task<unknown, unknown> for better type safety Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> * Initial plan * fix: Address PR #5 review comments - hook ordering, error handling, polyfills Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> * Initial plan * fix: Remove non-null assertions in web Task.test.ts to pass Biome lint Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> * fix: Use node: protocol for fs import in relay app Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> * fix: Add biome-ignore for intentional hook call in Vue useOwner Co-authored-by: miccy <9729864+miccy@users.noreply.github.com> --------- Signed-off-by: Miccy <code@miccy.dev> Co-authored-by: Daniel Steigerwald <daniel@steigerwald.cz> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent f2bb245 commit 25013bf

File tree

230 files changed

+3458
-7000
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

230 files changed

+3458
-7000
lines changed

.ai/knowledge/01-project-overview.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ Local-first database with sync capabilities for React, React Native, Svelte, and
1919
- Functional effect system for async operations
2020
- Replaces raw Promise patterns
2121
- Supports dependency injection via `runner.deps`
22+
- Uses `AsyncDisposableStack` for resource management
2223

2324
### Fiber/Runner
2425
- Execution context for Tasks
2526
- Manages abort signals and cleanup
2627
- Structured concurrency
28+
- Platform-specific implementations (`createRunner` for Node/Web)
2729

2830
### Console (Structured Logging)
2931
- JSON-structured log output

.ai/knowledge/03-bun-features.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Bun v1.3.7+ Features\n\n## Performance Optimization\n\n- Bun v1.3.7 introduces significant performance improvements in `async/await`, `Array.from`, and `array.flat`.\n- Leverage these improvements in performance-critical code paths, especially in `packages/common` and loop-heavy logic.\n\n## LLM-Friendly Builds\n\n- Use `bun build --metafile-md` to generate Markdown-formatted build metafiles.\n- This is useful for analyzing bundle size and dependencies with AI tools.\n- Consider adding a script: `"analyze": "bun build --metafile-md out/meta.md ..."`.\n\n## Markdown Support\n\n- Bun v1.3.8 adds a native Markdown parser: `Bun.markdown`.\n- This can replace external markdown parsers for simple use cases or documentation generation scripts.\n- Check if `typedoc-plugin-markdown` or other scripts can utilize this native feature.\n
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Structured Concurrency in Evolu
2+
3+
## Overview
4+
Evolu uses a custom implementation of structured concurrency to manage async operations, resource lifecycles, and cancellation. This replaces "fire and forget" promises with a strict tree structure where no child outlives its parent.
5+
6+
## Core Concepts
7+
8+
### Task
9+
A functional effect description (lazy promise) that requires a `Runner` to execute.
10+
11+
```typescript
12+
type Task<Success, Error = never, Deps = object> = (run: Runner<Deps>) => Promise<Result<Success, Error>>;
13+
```
14+
15+
### Runner
16+
The execution context. It provides:
17+
- Dependency injection (`run.deps`).
18+
- Abort signaling (cancellation propagation).
19+
- Resource management (via `AsyncDisposableStack`).
20+
21+
### Platform-Specific Runners
22+
As of `upstream/common-v8`, runners are platform-aware:
23+
24+
1. **Web (`packages/web`)**:
25+
- Hooks into `globalThis` for `error` and `unhandledrejection`.
26+
- Cleans up listeners on dispose.
27+
28+
2. **Node.js (`packages/nodejs`)**:
29+
- Hooks into `process` signals (`SIGINT`, `SIGTERM`, `SIGHUP`).
30+
- Provides graceful shutdown capabilities via `run.deps.shutdown`.
31+
32+
## Usage Pattern
33+
34+
### Creating a Runner
35+
**DO NOT** use generic `createRunner` directly for app entry points. Use the platform-specific library.
36+
37+
```typescript
38+
// Web
39+
import { createRunner } from "@evolu/web";
40+
// Node
41+
import { createRunner } from "@evolu/nodejs";
42+
43+
const main = async () => {
44+
await using run = createRunner();
45+
const result = await run(myTask);
46+
};
47+
```
48+
49+
### AsyncDisposableStack
50+
Resources that need cleanup should implement `AsyncDisposable` or be registered with the runner's stack environment.

.ai/knowledge/05-test-nuances.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Test Nuances & Known Flakes
2+
3+
## TreeShaking Tests
4+
**File**: `packages/common/test/TreeShaking.test.ts`
5+
6+
### Issue
7+
Bundle size measurements can fluctuate slightly (typically < 20 bytes) between different environments (local dev vs CI vs `bun verify`).
8+
9+
### Cause
10+
Likely differences in compression/minification details or environment-specific overhead in the test runner.
11+
12+
### Mitigation
13+
- If checks fail on size mismatch, use `bun test -u packages/common/test/TreeShaking.test.ts` to update snapshots locally.
14+
- Be aware that `verify` might fail purely due to this flake even if logic is correct.
15+
16+
## Bun Verify vs Bun Test
17+
`bun verify` runs the full monorepo check sequence. Sometimes `bun test` passes in isolation while `verify` fails due to cache/state issues.
18+
**Fix**: Run `bun run clean` in the failing package before retrying verification.

.ai/tasks/active/cherry-candidates-raw.txt

Lines changed: 0 additions & 162 deletions
This file was deleted.
File renamed without changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Bun Migration & Cleanup & Default Branch
2+
3+
> **Status**: ✅ Completed
4+
> **Last Updated**: 2026-02-03
5+
> **Branch**: `main`
6+
7+
## Summary
8+
Complete migration from pnpm/ESLint/Prettier to Bun/Biome across the entire monorepo. This replaces the complex cherry-pick strategy with a "Fresh Start" from `upstream/common-v8`.
9+
Also, set `main` as the default branch on GitHub.
10+
11+
## Tasks
12+
13+
- [x] **Cleanup Legacy Tooling**
14+
- [x] Remove `pnpm`-related files (`pnpm-lock.yaml`, `pnpm-workspace.yaml`, `.npmrc` if any)
15+
- [x] Remove `eslint`-related files (`.eslintrc`, `eslint.config.mjs`, `.eslintignore`, etc.)
16+
- [x] Remove `prettier`-related files (`.prettierrc`, `.prettierignore`, `prettier.config.mjs`)
17+
- [x] Scan and update `package.json` in all packages to remove `eslint`/`prettier` scripts and deps
18+
- [x] Run `bun run clean` & `bun install` to ensure clean state
19+
- [x] **Set Default Branch**
20+
- [x] Set `main` as default branch on `origin` (SQLoot/evolu-plan-b)
21+
- [x] **Verification**
22+
- [x] Verify build passes without legacy tools
23+
- [x] Verify `lint` command runs Biome only
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Merge & Integrate Upstream Commits
2+
3+
> **Status**: ✅ Completed
4+
> **Last Updated**: 2026-02-03
5+
> **Branch**: `sync/merge-upstream-03-02-26`
6+
7+
## Summary
8+
Integration of 14 commits from `upstream/common-v8` bringing significant changes to the Task runner architecture and tooling.
9+
10+
## Key Changes
11+
- **Structured Concurrency**:
12+
- `TaskDisposableStack` -> `AsyncDisposableStack`.
13+
- `runMain` -> `createRunner` (platform-specific implementations).
14+
- Web: Uses `globalThis` event listeners for error handling.
15+
- Node.js: Uses `process` signals (SIGINT, SIGTERM) for graceful shutdown.
16+
- **Relay**: `createNodeJsRelay` -> `startRelay`.
17+
- **Tooling**: Full removal of `pnpm` artifacts, reliance on Bun & Biome.
18+
19+
## Verification
20+
- `bun verify` passes (with caveats, see below).
21+
- Manual confirmation of `createRunner` types export.
22+
23+
## Known Issues
24+
- **TreeShaking Test**: `packages/common/test/TreeShaking.test.ts` shows minor bundle size fluctuations (~9 bytes) between local `bun test` and `bun verify` / CI. This is a known environmental flake.

.changeset/coderabbit-fixes.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@evolu/common": patch
3+
"@evolu/svelte": patch
4+
---
5+
6+
Fix Type compatibility issues identified by CodeRabbit:
7+
- `@evolu/common`: Update `CallbackWithCleanup` type for better strictness/compatibility.
8+
- `@evolu/svelte`: Update `$effect` signature to accept `void` return type.

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"

0 commit comments

Comments
 (0)