immerjs/immer
54.1
Adequate · 25 September 2026
5.9k
lines of production code
TypeScript
with JavaScript
4
measurements over time
What this system is
This system is the Immer library, a tool for creating and managing immutable state updates through a 'produce' function that utilizes draft objects. It provides core capabilities for structural sharing, automatic freezing, and patch generation, while supporting complex data structures like Maps and Sets via a plugin system. The codebase includes extensive performance benchmarking, comprehensive type definitions for TypeScript and Flow, and a modular architecture designed for high-performance state management.
How it got here
2017–2018 — Build modernization and test expansion
5 changes.
The project modernized its infrastructure by migrating the build system to tsup and the test runner to Vitest. This period also involved adding comprehensive test suites for core functionality, Flow types, and performance benchmarks to ensure stability and correctness.
2019–2025 — Architecture overhaul and documentation modernization
12 changes.
The project underwent a significant structural refactoring, migrating the test suite to Vitest, reorganizing source code into a modular architecture, and introducing new configuration APIs and performance optimizations. Concurrently, the documentation site was rebuilt using Docusaurus v2 with added Chinese localization, while comprehensive benchmarking tools were established to track performance improvements.
Features
Added Chinese (zh-CN) documentation translations
The website now includes a complete Chinese translation of the Immer documentation. This change adds the \zh-CN\ locale files, including sidebar labels and translated markdown pages for all core topics such as API reference, installation, array methods, and React integration, making the documentation accessible to Chinese-speaking users.
website/i18n · high confidence
Initial static assets for the documentation website
The documentation site now includes its foundational static files, specifically adding a \.nojekyll\ file to ensure static site generators like GitHub Pages serve the content correctly, and introducing the \immer-logo.svg\ image asset for use in the site's branding.
website/static · high confidence
Introduce Immer performance benchmarking and profiling tools
Added a new \perf-testing\ directory containing a complete benchmarking suite for Immer. This includes scripts (\immutability-benchmarks.mjs\, \immutability-profiling.mjs\) to compare performance across historical Immer versions (5–10), the current development build, and alternative libraries like Mutative, Structura, and Limu. The suite supports generating CPU profiles and analyzing them with sourcemap resolution (\read-cpuprofile.js\) to identify bottlenecks, along with a Rolldown bundler configuration to ensure production-grade benchmark results.
perf-testing · high confidence
Introduce \`current()\` utility and strict mode configuration options
Users can now use the new \current()\ function to take a snapshot of the current state of a draft and finalize it without freezing, which is useful for debugging or safely leaking draft state outside a producer. Additionally, the Immer class now exposes configuration options \useStrictShallowCopy\ and \useStrictIteration\ to control how object descriptors are copied and how iteration handles non-enumerable properties, allowing for stricter behavior or performance optimizations.
src/core · high confidence
New array method optimization plugin
The \src/plugins/arrayMethods.ts\ file introduces a new plugin that overrides standard array methods (such as \push\, \pop\, \sort\, \filter\, etc.) to avoid creating per-element proxies during iteration and mutation. This optimization significantly improves performance for array-heavy operations by operating directly on the draft copy and returning base values or drafts as appropriate, while ensuring structural sharing is preserved for no-op changes.
src/plugins · high confidence
Behavioural changes
Major overhaul of TypeScript and Flow type definitions
The type definitions in \src/types\ have been completely rewritten to improve type inference and performance. The new TypeScript types (\types-external.ts\) introduce advanced utility types like \Draft\, \Immutable\, and \WritableDraft\ to better handle complex state structures, including Maps, Sets, and tuples. The Flow definitions (\index.js.flow\) have been updated to match these changes, ensuring consistent type checking across both systems. Additionally, internal types (\types-internal.ts\) have been restructured to support the new draft mechanism, and a new \globals.d.ts\ file declares the \\_\DEV\\_\ constant.
src/types · high confidence
Migrate build system to tsup and test runner to Vitest
The project has replaced its previous build tooling with tsup, which now generates modern ESM and CJS bundles (including legacy ESM and production variants) with sourcemaps and minification. Concurrently, the test suite has migrated from Jest to Vitest, utilizing a custom reporter to handle snapshot logic and configuration files to manage test environments and coverage reporting.
(repo-wide) · high confidence
Migrate documentation site to Docusaurus v2 with updated analytics and styling
The documentation website has been rebuilt using Docusaurus v2, introducing a new configuration structure and custom CSS theme (immer-infima.css) that updates the visual style, including link colors and navbar appearance. This migration includes switching analytics from Universal Analytics (UA-65632006-3) to Google Analytics 4 (G-X43066885W), adding automatic URL redirections from /docs paths, enabling Chinese (zh-CN) localization, and displaying a support Ukraine announcement banner.
website · high confidence
Refactored internal utility modules for Immer
The internal utility code has been reorganized into distinct modules (common, env, errors, plugins) to improve structure and maintainability. This change introduces stricter validation for draftable objects, ensuring that \produce\ only accepts plain objects, arrays, Maps, Sets, or classes marked with \\[immerable\]: true\, and provides clearer error messages when non-draftable values are passed. It also standardizes the handling of Map and Set types through a dedicated plugin system and optimizes performance by caching constructor string checks in \isPlainObject\ and using \Reflect.ownKeys\ for strict iteration.
src/utils · high confidence
Restructured source code and exposed new configuration APIs
The library's source code has been reorganized into a modular structure with dedicated files for core logic, types, and plugins, replacing the previous flat layout. This change exposes several new configuration functions on the main export: \setUseStrictShallowCopy\ to control whether object descriptors are copied, \setUseStrictIteration\ to toggle between strict and loose property iteration, and \setAutoFreeze\ to manage automatic freezing of produced states. Additionally, the \Immer\ class is now exported, allowing users to create custom instances, while plugin enablement functions like \enableMapSet\ and \enablePatches\ are explicitly re-exported from their respective plugin modules.
src · high confidence
Test coverage
Added Flow type tests for core API and Map/Set support; Added comprehensive test suite for Immer core functionality; Added performance benchmarks for bulk data, incremental updates, and large objects; Added production error snapshots for Immer tests; Migrated test suite to Vitest with snapshot coverage.
Dependencies
Immer 10.0.3-beta: Modernized build tooling and test infrastructure
The Immer library has been updated to version 10.0.3-beta, introducing a modernized build and testing stack. The build system has migrated from TSDX and Bili to tsup, resulting in updated package exports that support ESM, CommonJS, and React Native environments. The test suite has been migrated from Jest to Vitest, and the performance testing infrastructure now utilizes rolldown for bundling. Additionally, the website documentation has been updated to use Docusaurus v2.
(dependencies) · high confidence
Housekeeping
Initial site generation for Immer documentation
The static site content for the Immer project has been generated, including the main README page with installation instructions and API documentation, as well as GitHub issue templates for bug reports and feature proposals.
_\site · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 41 → 54 (+13.5)
- Rubric changed (rubric-2026.08.15 → rubric-2026.09.15) — scores are not directly comparable.
Lenses
- Code Health 57 → 68 (+10.8)
- Architecture 80 (new)
- Maturity 54 → 59 (+5.3)
- Readiness 24 → 43 (+19.1)
- Security 65 → 65 (+0.1)
Resolved (83)
- Change coupling: base.js ↔ empty.ts (tests/base.js)
- Change coupling: base.js ↔ frozen.js (tests/base.js)
- Change coupling: base.js ↔ readme.js (tests/base.js)
- Change coupling: current.ts ↔ common.ts (src/core/current.ts)
- Change coupling: draft.ts ↔ immutable.ts (tests/draft.ts)
- Change coupling: draft.ts ↔ produce.ts (tests/draft.ts)
- Change coupling: empty.ts ↔ immer.ts (tests/empty.ts)
- Change coupling: immutable.ts ↔ produce.ts (tests/immutable.ts)
- Change coupling: null.js ↔ produce.ts (tests/null.js)
- Change coupling: proxy.ts ↔ scope.ts (src/core/proxy.ts)
- Critical CVE: [GHSA redacted] (yarn.lock)
- Critical CVE: [GHSA redacted] (perf-testing/yarn.lock)
- Critical CVE: [GHSA redacted] (yarn.lock)
- Critical CVE: [GHSA redacted] (yarn.lock)
- Dimension evaluation failed
- FileTooLong: tests/base.js (tests/base.js)
- FileTooLong: tests/patch.js (tests/patch.js)
- FileTooLong: tests/updateScenarios.js (tests/updateScenarios.js)
- FileTooLong: perf-testing/immutability-profiling.mjs (perf-testing/immutability-profiling.mjs)
- High CVE: [GHSA redacted] (yarn.lock)
- …and 63 more
New (127)
- Critical CVE: [GHSA redacted] (perf-testing/yarn.lock)
- Critical CVE: [GHSA redacted] (perf-testing/yarn.lock)
- Critical CVE: [GHSA redacted] (yarn.lock)
- Critical CVE: [GHSA redacted] (yarn.lock)
- FunctionTooLong: immutability-benchmarks.vanillaReducer (perf-testing/immutability-benchmarks.mjs)
- FunctionTooLong: mapset.enableMapSet (src/plugins/mapset.ts)
- FunctionTooLong: patches.enablePatches (src/plugins/patches.ts)
- High CVE: [GHSA redacted] (yarn.lock)
- High CVE: [GHSA redacted] (yarn.lock)
- High CVE: [GHSA redacted] (yarn.lock)
- High CVE: [GHSA redacted] (yarn.lock)
- High CVE: [GHSA redacted] (yarn.lock)
- High CVE: [GHSA redacted] (yarn.lock)
- High CVE: [GHSA redacted] (yarn.lock)
- High CVE: [GHSA redacted] (yarn.lock)
- High CVE: [GHSA redacted] (yarn.lock)
- High CVE: [GHSA redacted] (yarn.lock)
- High CVE: [GHSA redacted] (yarn.lock)
- High CVE: [GHSA redacted] (yarn.lock)
- High CVE: [GHSA redacted] (yarn.lock)
- …and 107 more
Changes since last survey
- 21 commits — 17 feature/other, 4 fixes
By area
- website/yarn.lock — 5 commits
- (root) — 4 commits
- tests/base.js — 3 commits
- website/docs — 3 commits
- src/plugins — 2 commits
- (repo) — 1 commit
- tests/prototype-inspection.js — 1 commit
- src/utils — 1 commit
- website/i18n — 1 commit
Notable commits
- fix: Fix existing copy usage check in getValue
- fix: Merge pull request #1289 from maximilliangrand/fix/array-methods-noop-structural-sharing
- fix: fix: preserve structural sharing for no-op array-methods calls
- fix: fix: remove global var Iterator declaration conflicting with ESNext lib (#1290)
- change: Add additional tests for array method cases
- change: Ensure array methods really do no-op correctly
- change: Skip new references for arrays when sort or reverse is a no-op
- change: chore(deps): bump brace-expansion from 1.1.14 to 1.1.18 in /website (#1287)
- change: chore(deps): bump fast-uri from 3.1.2 to 3.1.5 in /website (#1284)
- change: chore(deps): bump ip-address from 10.2.0 to 10.4.0 (#1282)
- change: chore(deps): bump nanoid from 3.3.12 to 3.3.18 in /website (#1288)
- change: chore(deps): bump postcss from 8.5.13 to 8.5.26 in /website (#1281)
- change: chore(deps): bump shell-quote from 1.8.4 to 1.10.0 (#1279)
- change: chore(deps): bump svgo from 2.8.2 to 2.8.3 in /website (#1291)
- change: chore(deps): bump tar from 7.5.16 to 7.5.22 (#1280)
- change: chore(deps-dev): bump immutable from 3.8.3 to 4.3.9 (#1277)
- change: chore(test): pin draft prototype-inspection behavior restored by #1271 (#1272)
- change: docs: add typed custom produce function (#1239)
- change: docs: add zh-CN array methods translation (#1285)
- change: docs: fix RFC-6902 JSON Pointer path conversion (#1274)
- …and 1 more
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
immerjs/immer was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 25 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 061c2425e1c9dff89e4e4189d42af1b7839dfe0a — the exact code this score is about.
- Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-dd72cc24c749.