{"id":25810,"library":"json-pipeline","title":"json-pipeline","description":"json-pipeline (v3.12.3) is a structure specification for designing flexible compilers with support for third-party optimization phases. It provides abstractions for sea-of-nodes (SoN), control flow graphs (CFG), static single assignment (SSA), dominator trees, and global code motion (GCM). The package is designed for Node.js and focuses on JSON-representable intermediate representations, making it suitable for compiler backends and JIT compilers. Release cadence is irregular; last major update was v3.0.0 with breaking changes in API. Key differentiators: modular architecture, JSON serialization, and emphasis on custom optimization phases.","status":"active","version":"3.12.3","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/indutny/json-pipeline","tags":["javascript","JSON","pipeline","CFG","SSA","Sea","of","nodes","Compiler"],"install":[{"cmd":"npm install json-pipeline","lang":"bash","label":"npm"},{"cmd":"yarn add json-pipeline","lang":"bash","label":"yarn"},{"cmd":"pnpm add json-pipeline","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export only; named import does not exist.","wrong":"const { Pipeline } = require('json-pipeline')","symbol":"Pipeline","correct":"import Pipeline from 'json-pipeline'"},{"note":"Node is a named export; Pipeline is default.","wrong":"import { Pipeline, Node } from 'json-pipeline'","symbol":"Node","correct":"import Pipeline, { Node } from 'json-pipeline'"},{"note":"Graph is a named export; ensure ESM import syntax.","wrong":"const Graph = require('json-pipeline').Graph","symbol":"Graph","correct":"import Pipeline, { Graph } from 'json-pipeline'"}],"quickstart":{"code":"import Pipeline, { Node, Graph } from 'json-pipeline';\n\n// Create a new pipeline\nconst pipeline = new Pipeline();\n\n// Create a graph\nconst graph = pipeline.createGraph();\n\n// Create nodes\nconst node1 = graph.createNode('add', { type: 'op' });\nnode1.setInput(0, graph.createNode('const', { value: 1 }));\nnode1.setInput(1, graph.createNode('const', { value: 2 }));\n\n// Set start/end nodes\ngraph.setStart(node1);\ngraph.setEnd(node1);\n\n// Serialize to JSON\nconst json = pipeline.toJSON();\nconsole.log(JSON.stringify(json, null, 2));\n\n// Deserialize\nconst restored = Pipeline.fromJSON(json);\nconsole.log(restored.graphs[0].nodes.length);","lang":"typescript","description":"Create a pipeline, build a graph with two constant nodes feeding into an add node, serialize to JSON, and deserialize."},"warnings":[{"fix":"Update to `new Pipeline({ /* options */ })`.","message":"v3.0.0 changed the API: Pipeline constructor now requires options object.","severity":"breaking","affected_versions":">=3.0.0 <4.0.0"},{"fix":"If you need immutability, clone the graph before modification.","message":"Node.setInput(index, node) does not clone nodes; mutates the graph structure in-place.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use `pipeline.createGraph({ name: 'myGraph' })` instead.","message":"pipeline.createGraph() is deprecated in favor of pipeline.createGraph(options).","severity":"deprecated","affected_versions":">=3.5.0"},{"fix":"Ensure node types match expected schema from documentation.","message":"Node types are not validated; invalid types may cause runtime errors.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Upgrade to v3.2.1 or later.","message":".toJSON() and .fromJSON() are not symmetric in v3.2.0 - due to internal ordering.","severity":"breaking","affected_versions":"==3.2.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use `import Pipeline from 'json-pipeline'` (default import).","cause":"Using named import instead of default import.","error":"TypeError: Pipeline is not a constructor"},{"fix":"Ensure nodes are created via `graph.createNode()` and added before using them as inputs.","cause":"Referencing a node that has not been added to the graph.","error":"Error: Node with id X not found"},{"fix":"Create nodes first, then set start/end.","cause":"graph.setStart() or graph.setEnd() called before nodes are created.","error":"Cannot read property 'setInput' of undefined"},{"fix":"Set the graph's start node using `graph.setStart(node)`.","cause":"Calling graph.toJSON() without setting a start node.","error":"AssertionError [ERR_ASSERTION]: Graph must have a start node"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}