greyscript-transpiler
v2.0.1
Published
Transpiler
Readme
greyscript-transpiler
A transpiler for GreyScript (the Grey Hack flavour of MiniScript) written in TypeScript. It extends greybel-transpiler with GreyScript-specific parsing and code generation via greyscript-core.
Features
- Extends
greybel-transpilerwith GreyScript-aware AST handling - 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- Optional
processImportPathCallbackfor custom import path rewriting - Written in TypeScript with type definitions included
Install
npm install greyscript-transpilerUsage
Single file (DirectTranspiler)
import { DirectTranspiler, BuildType } from 'greyscript-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 'greyscript-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