greybel-transpiler
v4.0.1
Published
Transpiler
Readme
greybel-transpiler
A transpiler for MiniScript written in TypeScript. It transforms MiniScript source files into deployable code and is built on top of greybel-core. For GreyScript-specific transpilation, see greyscript-transpiler.
Features
- Three build modes: default, beautify, and uglify
- Automatic dependency resolution for
#includeand#importdirectives - Variable and module namespace obfuscation
- Environment variable injection at transpile time
DirectTranspilerfor quick single-file transpilation without resource loadingTranspilerfor full multi-file builds with dependency graphs and installer output- Literal deduplication and namespace generation for compact output
- Written in TypeScript with type definitions included
Install
npm install greybel-transpilerUsage
Single file (DirectTranspiler)
import { DirectTranspiler, BuildType } from 'greybel-transpiler';
const result = new DirectTranspiler({
code: 'print "hello world"',
buildType: BuildType.BEAUTIFY,
obfuscation: false
}).parse();
console.log(result);Multi-file project (Transpiler)
import { Transpiler, BuildType } from 'greybel-transpiler';
const result = await new Transpiler({
target: '/path/to/main.src',
buildType: BuildType.DEFAULT,
obfuscation: true,
installer: true,
environmentVariables: new Map([['VERSION', '"1.0.0"']])
}).parse();
// result is a record of output filename to transpiled code
console.log(result);Build Types
| Type | Description |
|------|-------------|
| BuildType.DEFAULT | Emits code with minimal transformation |
| BuildType.BEAUTIFY | Pretty-prints the output with configurable indentation |
| BuildType.UGLIFY | Minifies the output for smaller file size |
Testing
npm test