Skip to content

[Roadmap] Mutative v2 #168

Description

@unadlib

Goal

Mutative v2 will focus on correctness, performance, smaller package output, and a better developer experience.

Correct by default. Faster when safe. Smaller and easier to adopt.

Plan

Core semantics

  • Improve shared-reference handling in nested create() calls.
  • Align with Immer where appropriate and document intentional differences.
  • Ensure enabling patches never changes the final state.
  • Verify that patches reproduce the result and inverse patches restore the original state.
  • Add coverage for shared references, nested drafts, sparse arrays, and complex array mutations.

Array performance

  • Use the conservative array implementation when patches are enabled.
  • Enable specialized array fast paths when patches are disabled.
  • Optimize high-impact operations such as shift(), unshift(), splice(), and reverse().
  • Ensure optimized and conservative paths always produce identical results.
  • Prevent performance regressions in sequential reads and full-array traversal.

Benchmarks

  • Build reproducible benchmarks for Mutative v1, Mutative v2, and a pinned Immer version.
  • Measure patch-enabled and patch-disabled modes separately.
  • Cover mutation-heavy, read-heavy, small-state, and large-state workloads.
  • Track execution time, memory usage, and common array operations.
  • Add performance regression budgets to CI.

Build system and bundle size

  • Migrate the build system from Rollup to tsdown.
  • Preserve existing ESM, CommonJS, UMD, development, and production outputs.
  • Preserve package exports and TypeScript declaration compatibility.
  • Configure the build target and platform explicitly.
  • Validate package output with publint and attw.
  • Reduce bundle size and add size regression checks.
  • Verify the final packed npm artifact before release.

Tooling

  • Upgrade pnpm and regenerate the lockfile.
  • Migrate the test suite from Jest to Vitest.
  • Preserve test behavior, coverage, mocks, snapshots, and timer semantics.
  • Update CI and the build environment for tsdown.
  • Keep tooling migrations separate from runtime changes.

Website and documentation

  • Refactor the website.
  • Add first-class Chinese language support.
  • Publish v2 benchmarks and methodology.
  • Add a v1-to-v2 migration guide.
  • Document patch behavior and important differences from Immer.
  • Keep the website refactor independent from the core runtime release.

Real-world validation

  • Test v2 in representative applications before the stable release.
  • Verify ESM, CommonJS, TypeScript, bundler, and supported Node.js compatibility.
  • Collect beta feedback and resolve correctness or compatibility blockers.
  • Define a maintenance window for Mutative v1.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions