tstmlog
raw JSON → 0.1.1 verified Fri May 01 auth: no javascript
tstmlog is a TypeScript-to-Mindustry Logic (mlog) compiler and transpiler (v0.1.1). It allows developers to write Mindustry processor code in TypeScript and compile it to .mlog files. As a minimal release, it focuses core translation rather than full feature parity. It uses the TypeScript compiler API and ships its own type definitions.
Common errors
error Error [ERR_REQUIRE_ESM]: require() of ES Module ...\node_modules\tstmlog\index.js not supported. ↓
cause Using CommonJS require() to load an ESM-only package.
fix
Change to import syntax or configure your project as ESM.
error Cannot find module 'typescript' ↓
cause TypeScript is not installed as a dependency.
fix
Run 'npm install typescript' or add it to your project's dependencies.
error SyntaxError: Unexpected token 'export' ↓
cause Using ESM syntax (import/export) in a CommonJS script without proper configuration.
fix
Set \"type\": \"module\" in package.json or rename file to .mjs.
Warnings
gotcha tstmlog requires the TypeScript compiler to be installed. If not present, the library will fail to load. ↓
fix Install TypeScript as a dependency: 'npm install typescript'
breaking tstmlog v0.1.1 is ESM-only. Import using ESM syntax; CommonJS require() will throw an error. ↓
fix Use import instead of require. Ensure package.json contains \"type\": \"module\" or use .mjs extension.
gotcha The compiled mlog output may not support all TypeScript features. Language subset limited to simple expressions and functions. ↓
fix Refer to documentation for supported TypeScript constructs; avoid advanced features like classes, generics, async/await.
deprecated The 'output' property in compiler options was deprecated in v0.1.1 in favor of 'target'. ↓
fix Use 'target' instead of 'output' when specifying mlog version.
Install
npm install tstmlog yarn add tstmlog pnpm add tstmlog Imports
- compile wrong
const compile = require('tstmlog').compilecorrectimport { compile } from 'tstmlog' - default wrong
const tstmlog = require('tstmlog')correctimport tstmlog from 'tstmlog' - CompilerOptions
import type { CompilerOptions } from 'tstmlog'
Quickstart
import { compile, CompilerOptions } from 'tstmlog';
const sourceCode = `
const x = 5;
const y = 10;
print(x + y);
`;
const options: CompilerOptions = {
target: 'latest',
minify: false
};
try {
const mlog = compile(sourceCode, options);
console.log(mlog);
} catch (error) {
console.error('Compilation failed:', error);
}