Registry / serialization / firescript-transpiler

firescript-transpiler

JSON →
library0.10.0jsnpmunverified

Transpiler module for Firescript, version 0.10.0. Provides two transpiler classes: JavascriptTranspiler to convert Firescript AST to JavaScript source code, and FirescriptTranspiler to output Firescript source. Low-level tool intended for building compilers or tooling around Firescript. Release cadence is unknown.

npm install firescript-transpiler
INSTALL
IMPORT
SIG · FIRESCRIPT-TRANSPI
F
firescript-transpiler
serializationjavascriptv0.10.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.

JavascriptTranspiler
✓ import JavascriptTranspiler from 'firescript-transpiler'
Default export; no named exports.
FirescriptTranspiler
✓ import FirescriptTranspiler from 'firescript-transpiler'
Same default export module, but a different class. Both are exported as the default, so importing them separately does not work; you need to destructure or import the default once. Actually, the README example shows two separate default imports which is invalid. The correct way is to import the default once and then access both classes: import TranspilerModule from 'firescript-transpiler'; const { JavascriptTranspiler, FirescriptTranspiler } = TranspilerModule;
require (CommonJS)
✓ const { JavascriptTranspiler, FirescriptTranspiler } = require('firescript-transpiler')
✗ const JavascriptTranspiler = require('firescript-transpiler')
CommonJS users must destructure because the module exports an object with both classes.

Shows how to import and use both transpiler classes to convert a Firescript AST to JavaScript and Firescript source.

import { JavascriptTranspiler, FirescriptTranspiler } from 'firescript-transpiler'; import { parse } from 'firescript-parser'; // hypothetical parser const source = 'let x = 5'; const ast = parse(source); const jsTranspiler = new JavascriptTranspiler(); const jsCode = jsTranspiler.transpile(ast); console.log(jsCode); const fsTranspiler = new FirescriptTranspiler(); const fsCode = fsTranspiler.transpile(ast); console.log(fsCode);
Debug
Known issues
gotchaBoth classes are exported as default exports from the same module, so you cannot import them separately via two default imports.
fix
Use a single default import and destructure: import TranspilerModule from 'firescript-transpiler'; const { JavascriptTranspiler, FirescriptTranspiler } = TranspilerModule;
affects: >=0.10.0
gotchaThe transpiler expects an AST object, not source code string. Passing a string will throw an error.
fix
First parse the source with a Firescript parser (e.g., firescript-parser) to get an AST, then pass it to transpile().
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: transpiler.transpile is not a function
The transpiler instance was not created correctly; likely using default import without instantiation.
fix
const transpiler = new JavascriptTranspiler(); then transpiler.transpile(ast);
SyntaxError: Unexpected token 'export'
Using ES module import syntax in a CommonJS environment without transpilation.
fix
Use CommonJS require: const { JavascriptTranspiler } = require('firescript-transpiler');
Upgrade
Version history
0.10.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
firescript-transpiler — npm install firescript-transpiler · libregistry