{"id":26502,"library":"transpiler","title":"transpiler","description":"AST-based transpiler wrapper for Node.js, version 1.2.0 (last release unknown, appears stable but rarely updated). It provides a simple way to define node handlers that transform AST nodes into strings. Unlike full-featured compiler toolkits like Babel, it is focused on lightweight, minimal transpilation without dependencies. Supports overrides per transpile call.","status":"maintenance","version":"1.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/asmblah/transpiler","tags":["javascript","ast","transpile"],"install":[{"cmd":"npm install transpiler","lang":"bash","label":"npm"},{"cmd":"yarn add transpiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add transpiler","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Both forms work; destructuring is common in modern code.","wrong":"const transpiler = require('transpiler').create(spec);\n// Also works but less consistent","symbol":"create","correct":"const { create } = require('transpiler');\nconst transpiler = create(spec);"},{"note":"No constructor exposed; use create() function.","wrong":"const myTranspiler = new Transpiler(spec); // No class export","symbol":"transpiler instance","correct":"const myTranspiler = create(spec);\nmyTranspiler.transpile(ast);"},{"note":"Second argument must be data (or null), third is options.","wrong":"myTranspiler.transpile(ast, options); // Missing data param","symbol":"transpile method","correct":"myTranspiler.transpile(ast, data, options);"}],"quickstart":{"code":"const { create } = require('transpiler');\n\nconst spec = {\n  nodes: {\n    'EXPR': function(node, transpile) {\n      return transpile(node.left) + ' ' + node.operator + ' ' + transpile(node.right);\n    },\n    'OPERAND': function(node) {\n      return node.value;\n    }\n  }\n};\n\nconst transpiler = create(spec);\nconst ast = {\n  name: 'EXPR',\n  left: { name: 'OPERAND', value: 21 },\n  operator: '+',\n  right: { name: 'OPERAND', value: 27 }\n};\n\nconsole.log(transpiler.transpile(ast)); // '21 + 27'","lang":"javascript","description":"Creates a basic arithmetic transpiler from AST spec and transpiles an expression."},"warnings":[{"fix":"Update calls to pass null as second argument if no data is needed: transpile(ast, null, options).","message":"In version 1.0.0, the 'transpile' method changed signature from (ast, options) to (ast, data, options).","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Inside handler, use the local 'transpile' function to compile child nodes, not the instance method.","message":"Node handlers receive 'transpile' as second argument; easily confused with the instance's 'transpile' method.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always pass the node to original: original(node).","message":"The 'original' function in overrides refers to the default handler for that node; calling 'original(node)' without arguments may cause issues if the handler expects more parameters.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use a different library if you need async; this one is synchronous only.","message":"Package is purely synchronous; cannot handle async transpilation steps.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use const transpiler = require('transpiler').create(spec); or destructure create.","cause":"Imported the module incorrectly, e.g., const transpiler = require('transpiler'); instead of calling create().","error":"TypeError: transpiler.transpile is not a function"},{"fix":"Ensure AST has the required fields (e.g., left, right).","cause":"AST node missing expected properties or handler not receiving the full node structure.","error":"TypeError: node.left is undefined"},{"fix":"Add a handler for that node type in the spec or in options overrides.","cause":"Transpiler spec does not define a handler for the node type 'XYZ'.","error":"Error: Unknown node type 'XYZ'"},{"fix":"Check AST for cycles or ensure base cases in handlers.","cause":"Recursive or circular AST structure causing infinite recursion in transpile.","error":"RangeError: Maximum call stack size exceeded"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}