CodeVetter · Repo Unpack · System map
pmndrs/valtio
The primary product is a library with separate vanilla and React runtime boundaries. Its state resides in JavaScript objects and runtime caches; persistence is supplied by consuming applications. Rollup produces publishable CommonJS, ESM, and declaration artifacts, while the documentation website and examples have separate application configurations. The inspected workflows describe validation and package publication, without establishing their execution results.
- src/index.ts re-exports vanilla and React APIs; src/utils.ts similarly combines vanilla utilities with React utilities, allowing consumers to choose narrower subpath imports.
- The vanilla runtime owns proxyStateMap, refSet, snapCache, proxyCache, and a shared versionHolder; each ProxyState contains the target, ensureVersion, and addListener.
- The React layer depends on useSyncExternalStore and proxy-compare's createProxy/isChanged, while the vanilla layer imports only proxy-compare helpers; React and its types are optional peers requiring version 18 or newer.
- Package exports select CJS .js/.d.ts artifacts by default and for react-native, or ESM .mjs/.d.mts artifacts for imports; typesVersions provides a fallback declaration for TypeScript versions below 4.5.
- Six build scripts select Rollup entrypoints; the config emits ES2018 CJS/ESM bundles and declarations, while postbuild rewrites declaration imports, copies metadata, and makes the dist manifest publishable.
- The pnpm workspace includes only the root and website; Vite examples have separate manifests, and their inspected configs enable React plugins, with the starter using the SWC variant.
- The website uses Next.js pages with a landing route and statically enumerated /docs/[...slug] pages; its scripts expose next dev/build/start, and styling uses class-based Tailwind dark mode and typography.
- Root validation scripts cover formatting, types, lint, and Vitest; release publication builds and publishes from dist, while push/PR preview publication uses pkg-pr-new with example templates.