{"id":25056,"library":"carmi","title":"CARMI","description":"CARMI (Compiler for Automatic Reactive Modelling of Inference) is an experimental DSL+compiler for reactive state derivation. Current version 1.0.342. It generates JavaScript source code that automatically handles cache invalidation by analyzing which model paths are read/written at compile time, avoiding overhead of traditional FRP or immutable approaches. Key differentiators: zero-overhead conditional dependency tracking, hoisted shared sub-expressions, no tracking when no setters exist, fully incremental computation. Stable but low release cadence (last major update years ago). Ships TypeScript types.","status":"active","version":"1.0.342","language":"javascript","source_language":"en","source_url":"https://github.com/wix-incubator/carmi","tags":["javascript","typescript"],"install":[{"cmd":"npm install carmi","lang":"bash","label":"npm"},{"cmd":"yarn add carmi","lang":"bash","label":"yarn"},{"cmd":"pnpm add carmi","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package supports both ESM and CJS; this is the named import.","wrong":"const compile = require('carmi')","symbol":"compile","correct":"import { compile } from 'carmi'"},{"note":"Named import, not default.","wrong":"const root = require('carmi').root","symbol":"root","correct":"import { root } from 'carmi'"},{"note":"setter is exported from main package, not a subpath.","wrong":"const setter = require('carmi/setter')","symbol":"setter","correct":"import { setter } from 'carmi'"},{"note":"Correct both ways; no wrong pattern for named import.","wrong":"const { splice } = require('carmi')","symbol":"splice","correct":"import { splice } from 'carmi'"}],"quickstart":{"code":"import { compile, root, arg0, setter, splice } from 'carmi';\n\nconst todosByIdx = root.keyBy('idx');\nconst anyTodoNotDone = todosByIdx.anyValues(todo => todo.get('done').not());\nconst todosDisplayByIdx = todosByIdx.mapValues(todo =>\n  todo.get('task').plus(todo.get('done').ternary(' - done', ' - not done'))\n);\nconst todosDisplay = root.map(todo => todosDisplayByIdx.get(todo.get('idx')));\n\nconst modelDefinition = {\n  todosDisplay,\n  anyTodoNotDone,\n  setTodoDone: setter(arg0, 'done'),\n  spliceTodos: splice(),\n};\n\nconst todosModel = eval(compile(modelDefinition));\nconst initialData = [\n  { idx: '1', done: false, task: 'write a blog post about carmi' },\n  { idx: '2', done: true, task: 'publish to npm' },\n  { idx: '3', done: false, task: 'write a demo for carmi' },\n];\nconst todos = todosModel(initialData);\nconsole.log(todos.todosDisplay);\n// outputs array with tasks marked done/not done sorted by idx descending","lang":"javascript","description":"Defines a reactive model for a todo list: derived display text, any-not-done flag, and a setter action using compile/eval."},"warnings":[{"fix":"Use eval(compile(modelDefinition)) as shown in docs.","message":"compile() returns a string; you must eval() it to get the model function.","severity":"gotcha","affected_versions":"*"},{"fix":"Always use .get('key') to access model properties if you need the value.","message":"The DSL uses method chaining on root; forgetting .get() on properties returns a Path object, not a value.","severity":"gotcha","affected_versions":"*"},{"fix":"Replace import { compile } from 'carmi/macro' with import { compile } from 'carmi'.","message":"The Babel macro approach (require('carmi/macro')) is no longer recommended; use compile() directly.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Ensure that the number and order of args match the paths used in setter(arg0, ...).","message":"Setters generated by setter() expect arguments in model index order; mismatch causes silent failures.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Change const model = compile(definition); to const model = eval(compile(definition));","cause":"compile() returns a string, not a function. You forgot to eval() it.","error":"TypeError: model is not a function"},{"fix":"Ensure your model definition uses root and paths correctly; verify that the compiled code runs inside eval.","cause":"Attempting to chain .get() on a model accessor that returned undefined in eval context.","error":"Cannot read property 'get' of undefined"},{"fix":"Add import { root } from 'carmi' at top of the file where compile() is called.","cause":"Forgetting to import or destructure root from carmi in the compile scope.","error":"ReferenceError: root is not defined"},{"fix":"Use setter(arg0, 'pathToSet') or setter(arg0, arg1) depending on your model depth.","cause":"setter() called without any arguments or with non-function arguments.","error":"Error: setter requires at least one path argument"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}