greyscript-transpiler
raw JSON → 2.0.1 verified Fri May 01 auth: no javascript
A TypeScript-based transpiler for GreyScript (Grey Hack MiniScript flavour), extending greybel-transpiler with GreyScript-specific AST parsing and code generation. Current stable version 2.0.1. Features three build modes (default, beautify, uglify), automatic dependency resolution, variable/module name obfuscation, environment variable injection, and installer output. Includes DirectTranspiler for single-file and full Transpiler for multi-file projects. Ships with TypeScript type definitions. Part of the greybel ecosystem.
Common errors
error Cannot find module 'greyscript-transpiler' ↓
cause Package not installed or not in node_modules.
fix
Run
npm install greyscript-transpiler --save error TypeError: transpiler.parse is not a function ↓
cause Using Transpiler class without awaiting the promise; Transpiler.parse() is async and returns a Promise.
fix
Await the result:
const result = await transpiler.parse(); error Property 'DEFAULT' does not exist on type 'typeof BuildType'. ↓
cause Attempted to use BuildType.DEFAULT without importing BuildType correctly.
fix
Import BuildType:
import { BuildType } from 'greyscript-transpiler'; then use BuildType.DEFAULT. Warnings
breaking Version 2.0.0 changed the API: Transpiler constructor now requires `target` instead of `code`; DirectTranspiler introduced for string input. ↓
fix Use DirectTranspiler for string code input; for file-based projects, pass `target` path to Transpiler.
deprecated Deprecation of `buildType` as a string; use BuildType enum imported from package. ↓
fix Replace string build type with enum: BuildType.DEFAULT, BuildType.BEAUTIFY, BuildType.UGLIFY.
gotcha Obfuscation renames variables, which can break scripts that rely on variable names (e.g., for reflection). ↓
fix Disable obfuscation by setting `obfuscation: false` in options if variable names must be preserved.
Install
npm install greyscript-transpiler yarn add greyscript-transpiler pnpm add greyscript-transpiler Imports
- DirectTranspiler wrong
const DirectTranspiler = require('greyscript-transpiler').DirectTranspilercorrectimport { DirectTranspiler } from 'greyscript-transpiler' - Transpiler wrong
const { Transpiler } = require('greyscript-transpiler').Transpilercorrectimport { Transpiler } from 'greyscript-transpiler' - BuildType wrong
import BuildType from 'greyscript-transpiler'correctimport { BuildType } from 'greyscript-transpiler' - DirectTranspilerOptions wrong
import { DirectTranspilerOptions } from 'greyscript-transpiler'correctimport type { DirectTranspilerOptions } from 'greyscript-transpiler'
Quickstart
import { DirectTranspiler, BuildType } from 'greyscript-transpiler';
const transpiler = new DirectTranspiler({
code: 'print "hello world"',
buildType: BuildType.BEAUTIFY,
obfuscation: false
});
const result = transpiler.parse();
console.log(result);