Registry / serialization / transpiler

transpiler

JSON →
library1.2.0jsnpmunverified

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.

npm install transpiler
INSTALL
IMPORT
SIG · TRANSPILER
T
transpiler
serializationjavascriptv1.2.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

create
✓ const { create } = require('transpiler'); const transpiler = create(spec);
✗ const transpiler = require('transpiler').create(spec); // Also works but less consistent
Both forms work; destructuring is common in modern code.
transpiler instance
✓ const myTranspiler = create(spec); myTranspiler.transpile(ast);
✗ const myTranspiler = new Transpiler(spec); // No class export
No constructor exposed; use create() function.
transpile method
✓ myTranspiler.transpile(ast, data, options);
✗ myTranspiler.transpile(ast, options); // Missing data param
Second argument must be data (or null), third is options.

Creates a basic arithmetic transpiler from AST spec and transpiles an expression.

const { create } = require('transpiler'); const spec = { nodes: { 'EXPR': function(node, transpile) { return transpile(node.left) + ' ' + node.operator + ' ' + transpile(node.right); }, 'OPERAND': function(node) { return node.value; } } }; const transpiler = create(spec); const ast = { name: 'EXPR', left: { name: 'OPERAND', value: 21 }, operator: '+', right: { name: 'OPERAND', value: 27 } }; console.log(transpiler.transpile(ast)); // '21 + 27'
Debug
Known issues
breakingIn version 1.0.0, the 'transpile' method changed signature from (ast, options) to (ast, data, options).
fix
Update calls to pass null as second argument if no data is needed: transpile(ast, null, options).
affects: <1.0.0
gotchaNode handlers receive 'transpile' as second argument; easily confused with the instance's 'transpile' method.
fix
Inside handler, use the local 'transpile' function to compile child nodes, not the instance method.
affects: >=1.0.0
gotchaThe '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.
fix
Always pass the node to original: original(node).
affects: >=1.0.0
gotchaPackage is purely synchronous; cannot handle async transpilation steps.
fix
Use a different library if you need async; this one is synchronous only.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: transpiler.transpile is not a function
Imported the module incorrectly, e.g., const transpiler = require('transpiler'); instead of calling create().
fix
Use const transpiler = require('transpiler').create(spec); or destructure create.
TypeError: node.left is undefined
AST node missing expected properties or handler not receiving the full node structure.
fix
Ensure AST has the required fields (e.g., left, right).
Error: Unknown node type 'XYZ'
Transpiler spec does not define a handler for the node type 'XYZ'.
fix
Add a handler for that node type in the spec or in options overrides.
RangeError: Maximum call stack size exceeded
Recursive or circular AST structure causing infinite recursion in transpile.
fix
Check AST for cycles or ensure base cases in handlers.
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
transpiler — npm install transpiler · libregistry