Registry / web-framework / ccstate-babel

ccstate-babel

JSON →
library5.2.3jsnpmunverified

A Babel preset for CCState v5.2.3 that provides Hot Module Reload support and automatic debug label injection for atoms. It adds a global cacheMap to make each atom a singleton under HMR, and automatically generates debug information for easier troubleshooting. The preset is configurable via options like projectRoot and customAtomNames (default: ['state', 'computed', 'command']). Designed as a build-time tool, it integrates seamlessly with Vite and other Babel-based setups. Differentiators include first-class HMR support and auto-labeling, inspired by Jotai's devtools.

npm install ccstate-babel
INSTALL
IMPORT
SIG · CCSTATE-BABEL
C
ccstate-babel
web-frameworkjavascriptv5.2.3
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (preset)
✓ import { preset } from 'ccstate-babel'
✗ import ccstateBabel from 'ccstate-babel'
The preset is exported as a named export 'preset' from the main entry. Default export is not available.
preset (via paths)
✓ // babel.config.json "presets": ["ccstate-babel/preset"]
✗ "presets": ["ccstate-babel"]
Use the full path 'ccstate-babel/preset' in babel config, not just the package name.
usePreset in Vite
✓ const react = require('@vitejs/plugin-react'); ... plugins: [react({ babel: { presets: ['ccstate-babel/preset'] } })]
✗ plugins: [react({ babel: { presets: ['ccstate-babel'] } })]
Ensure the preset path is 'ccstate-babel/preset' within the babel object, not the outer level.

Shows how to configure the Babel preset in both babel.config.json and Vite setup, including custom atom names.

// Install // npm install --save-dev ccstate-babel @babel/core // babel.config.json { "presets": [ ["ccstate-babel/preset", { "projectRoot": __dirname, "customAtomNames": ["state", "computed", "command", "$action"] }] ] } // Then use in a Vite project (vite.config.ts) import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; export default defineConfig({ plugins: [ react({ babel: { presets: [ ['ccstate-babel/preset', { projectRoot: __dirname }] ] } }) ] }); // After configuration, atom calls like state(0) will be transformed for HMR and debug labels.
Debug
Known issues
breakingVersion 5.x requires CCState 5.x; incompatible with older atom signatures.
fix
Upgrade CCState to 5.x and ensure atom definitions use the new API (e.g., state() instead of atom()).
affects: >=5.0.0
deprecatedSupport for Node <12 has been dropped since v4.0.0.
fix
Use Node 12+.
affects: >=4.0.0
gotchaThe preset alters atom behavior for HMR; if HMR is not used, still adds overhead due to global cacheMap.
fix
Disable preset in production build or configure to skip HMR logic (not directly supported; consider forking).
affects: >=5.0.0
Errors
Common errors & fixes
Error: Cannot find module 'ccstate-babel/preset'
Missing or incorrectly placed package installation, or wrong babel config path.
fix
Ensure ccstate-babel is installed as a dev dependency and use the correct preset path: 'ccstate-babel/preset'.
TypeError: ccstate_babel.preset is not a function
Using default import instead of named import in JavaScript babel config.
fix
Use require('ccstate-babel').preset or import { preset } from 'ccstate-babel'.
Error: Options must be an object or undefined
Passing options incorrectly in babel config (e.g., string instead of object).
fix
Ensure second argument is an object: ['ccstate-babel/preset', { projectRoot: __dirname }]
Upgrade
Version history
5.2.3latest on npm
Audit
Dependencies
@babel/corerequiredRequired peer dependency for Babel plugin functionality
ccstateoptionalRuntime dependency for atom definitions; only needed if used at runtime (unlikely for a babel plugin, but imported in tests)
Agent activity
10 hits · last 30 days
node
8
OpenAI (training)
1
Resources
ccstate-babel — npm install ccstate-babel · libregistry