SetlX.js Transpiler
raw JSON → 1.4.0 verified Fri May 01 auth: no javascript
A transpiler that converts SetlX (a set-theoretic programming language) source code into JavaScript. Version 1.4.0 is the latest stable release; the project is in active development with irregular release cadence. It aims to bring the expressive set operations and functional programming paradigms of SetlX to the JavaScript ecosystem. Differentiated from general transpilers by its specific focus on SetlX language constructs, including sets, tuples, and comprehensions. Originally part of the setlxjs project with CLI and lib packages. Requires separate setlxjs-lib runtime library for execution.
Common errors
error Cannot find module 'setlxjs-lib' ↓
cause The transpiled code expects the runtime library setlxjs-lib but it is not installed.
fix
Run 'npm install setlxjs-lib' in your project that will execute the transpiled output.
error TypeError: transpile is not a function ↓
cause Using CommonJS require without destructuring, obtaining the module object instead of the function.
fix
Use 'const { transpile } = require('setlxjs-transpiler');' or 'import { transpile } from 'setlxjs-transpiler';'.
error SyntaxError: Unexpected token 'export' ↓
cause The package uses ESM exports but is being required in a CommonJS environment without transpilation.
fix
Use dynamic import() in CommonJS, or use a bundler that handles ESM/CJS interop.
Warnings
gotcha The transpiled JavaScript requires the setlxjs-lib runtime library to be available in the execution environment. ↓
fix Install setlxjs-lib and include its bundle in your project (e.g., via script tag or require).
breaking Version 1.0.0 adopted ESM-style exports; old CommonJS require patterns stopped working. ↓
fix Use dynamic import or update to Node.js with ESM support. For CommonJS, use 'const { transpile } = require('setlxjs-transpiler');'.
deprecated The package no longer bundles the CLI. Use setlxjs-cli separately for command-line usage. ↓
fix Install setlxjs-cli globally: 'npm install -g setlxjs-cli'.
Install
npm install setlxjs-transpiler yarn add setlxjs-transpiler pnpm add setlxjs-transpiler Imports
- transpile wrong
const transpile = require('setlxjs-transpiler').transpilecorrectimport { transpile } from 'setlxjs-transpiler' - default wrong
import { default } from 'setlxjs-transpiler'correctimport transpiler from 'setlxjs-transpiler' - transpile (CommonJS) wrong
const transpile = require('setlxjs-transpiler')correctconst { transpile } = require('setlxjs-transpiler')
Quickstart
import { transpile } from 'setlxjs-transpiler';
const setlxCode = `
s := {1,2,3};
t := {3,4,5};
print(s * t); // intersection
`;
try {
const jsCode = transpile(setlxCode);
console.log(jsCode);
// Output JavaScript that can be evaluated with setlxjs-lib
} catch (error) {
console.error('Transpilation failed:', error.message);
}