greybel-transpiler
raw JSON → 4.0.1 verified Fri May 01 auth: no javascript
MiniScript transpiler written in TypeScript that converts MiniScript source files into deployable code with three build modes: default, beautify, and uglify. Version 4.0.1 supports automatic dependency resolution for #include and #import directives, variable/module namespace obfuscation, environment variable injection at transpile time, and literal deduplication. It offers both DirectTranspiler for quick single-file transpilation and Transpiler for full multi-file builds with dependency graphs and installer output. Built on greybel-core, it targets the MiniScript ecosystem and includes TypeScript type definitions.
Common errors
error Cannot find module 'greybel-transpiler' or its corresponding type declarations. ↓
cause Package not installed or not imported correctly.
fix
Run npm install greybel-transpiler. Use import { DirectTranspiler } from 'greybel-transpiler' with correct named export.
error TypeError: DirectTranspiler is not a constructor ↓
cause Default import used instead of named import.
fix
Use import { DirectTranspiler } from 'greybel-transpiler' instead of import DirectTranspiler from ...
error Property 'BuildType' does not exist on type 'typeof import(...)' ↓
cause Misspelled BuildType as BuildTypes or similar.
fix
Correct the import to { BuildType }.
Warnings
gotcha DirectTranspiler does not resolve #include or #import dependencies; it only parses the given code string. Use Transpiler for dependency resolution. ↓
fix Use Transpiler with target file path instead of DirectTranspiler when needing dependency resolution.
breaking Version 4.x may have breaking changes from 3.x; check changelog for specific migration steps. ↓
fix Review greybel-transpiler changelog and update code accordingly.
gotcha Obfuscation is enabled by default in Transpiler? Verify the constructor option; if obfuscation is not set, it may default to true. The README example sets it explicitly. ↓
fix Always explicitly set obfuscation: false if you don't want variable name mangling.
deprecated BuildType enum values might change; ensure you use the string 'BuildType.BEAUTIFY' not deprecated string literals. ↓
fix Use imported BuildType enum, not hardcoded strings.
Install
npm install greybel-transpiler yarn add greybel-transpiler pnpm add greybel-transpiler Imports
- DirectTranspiler wrong
const DirectTranspiler = require('greybel-transpiler').DirectTranspilercorrectimport { DirectTranspiler } from 'greybel-transpiler' - Transpiler wrong
import Transpiler from 'greybel-transpiler'correctimport { Transpiler } from 'greybel-transpiler' - BuildType wrong
import { BuildTypes } from 'greybel-transpiler'correctimport { BuildType } from 'greybel-transpiler' - greybel-transpiler wrong
const greybel = require('greybel-transpiler')correct
Quickstart
import { DirectTranspiler, BuildType } from 'greybel-transpiler';
const result = new DirectTranspiler({
code: 'print "hello world"',
buildType: BuildType.BEAUTIFY,
obfuscation: false
}).parse();
console.log(result);
// Or multi-file with Transpiler:
import { Transpiler, BuildType } from 'greybel-transpiler';
const result2 = await new Transpiler({
target: '/path/to/main.src',
buildType: BuildType.DEFAULT,
obfuscation: true,
installer: true,
environmentVariables: new Map([['VERSION', '"1.0.0"']])
}).parse();
console.log(result2);