CodeVetter · Repo Unpack · System map
immerjs/immer
The principal runtime is an in-process state transformation library whose public entrypoint is src/immer.ts. Core modules manage proxies, execution scopes, snapshots, and finalization, while three optional plugins supply collection, patch, and array-method behavior. Distribution includes multiple JavaScript module formats and declarations; documentation and benchmarking have separate manifests and execution boundaries.
- src/immer.ts constructs one default Immer instance and exposes its produce method plus bound patch, configuration, and manual-draft methods; it also exports Immer for independent instances.
- src/internal.ts is the shared barrel connecting utility constants, errors, types, plugin interfaces, scopes, finalization, proxies, Immer, and current snapshots.
- Each producer scope owns draft references, optional forward/inverse patches, parent scope, finalization tracking sets, and its Immer instance; currentScope is module-level execution state.
- Package export conditions select legacy ESM for React Native, modern ESM for imports, and a CJS dispatcher for require, with dist/immer.d.ts supplied across these conditions.
- tsup builds declarations, development ESM/CJS, legacy ESM targeting es2017, and minified production ESM/CJS; production builds replace NODE_ENV and mangle properties ending in an underscore.
- The root package uses Yarn-oriented scripts for source tests, built-package tests, Flow checks, coverage, performance workloads, import-size reports, and semantic-release.
- The separate React/Docusaurus website serves documentation at routeBasePath '/', supports English and zh-CN, and deploys website/build to gh-pages through its public-docs workflow.
- perf-testing is a private ESM package using Mitata and Rolldown; aliases connect its current-development comparison to ../dist/immer.mjs alongside historical Immer versions and alternative libraries.