{"id":25945,"library":"mlogx","title":"MLOGX","description":"MLOGX is a transpiler and toolchain for Mindustry Logic (MLOG), the scripting language of the game Mindustry. Version 2.7.2 provides validation, readability improvements (e.g., infix operators, printf), compiler constants, loops, and multi-file support. It is actively maintained with frequent releases. Unlike raw MLOG, MLOGX catches invalid commands and type mismatches at compile time. It ships TypeScript types and supports both CLI and API usage.","status":"active","version":"2.7.2","language":"javascript","source_language":"en","source_url":"https://github.com/BalaM314/mlogx","tags":["javascript","mindustry","compiler","transpiler","mindustry-logic","mlog","mlogx","typescript"],"install":[{"cmd":"npm install mlogx","lang":"bash","label":"npm"},{"cmd":"yarn add mlogx","lang":"bash","label":"yarn"},{"cmd":"pnpm add mlogx","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package is ESM-only since v2. Use dynamic import() if you need CJS.","wrong":"const { compile } = require('mlogx')","symbol":"compile","correct":"import { compile } from 'mlogx'"},{"note":"Default export is the main transpile function. Named export 'compile' is preferred.","wrong":"const mlogx = require('mlogx')","symbol":"default (transpile function)","correct":"import transpile from 'mlogx'"},{"note":"TypeScript users should import types with 'import type' to avoid runtime inclusion.","wrong":"","symbol":"type CompileOptions","correct":"import type { CompileOptions } from 'mlogx'"}],"quickstart":{"code":"import { compile, writeOutput } from 'mlogx';\nimport { readFileSync } from 'fs';\n\nconst source = readFileSync('example.mlogx', 'utf8');\nconst result = compile(source, {\n  filename: 'example.mlogx',\n  targetVersion: 7,\n  format: 'mlog'\n});\nconsole.log(result.code);\nwriteOutput(result, './out/output.txt');\n// Output: compiled MLOG with error checks","lang":"typescript","description":"Compiles an MLOGX file to MLOG, showing the basic API usage."},"warnings":[{"fix":"Update CLI usage: `mlogx compile input.mlogx -o output.mlog`. If using the API, switch to async `compile(source, options)`.","message":"The CLI changed from `mlogx <file>` to `mlogx compile <file>` in v2.0, and the API changed from synchronous to asynchronous.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Change `import mlogx from 'mlogx'` to `import { compile } from 'mlogx'`.","message":"Default export removed in v2. Use named import `{ compile }` instead.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Always pass the full result object from `compile()` to `writeOutput()`.","message":"The `writeOutput` function expects an object with `code` and optionally `warnings` – not a raw string.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Use `mlogx convert input.mlog -o output.mlogx` instead of `mlogx port`.","message":"`mlogx port` command is deprecated in favor of `mlogx convert`.","severity":"deprecated","affected_versions":">=2.5.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use `import mlogx from 'mlogx'` or `const { compile } = await import('mlogx')`.","cause":"Using `require('mlogx')` in an ESM context.","error":"ReferenceError: mlogx is not defined"},{"fix":"Replace `import { transpile } from 'mlogx'` with `import { compile } from 'mlogx'`.","cause":"The main function is named `compile`, not `transpile`.","error":"Module 'mlogx' has no exported member 'transpile'"},{"fix":"Run `npm install -g mlogx` or use `npx mlogx`.","cause":"Global installation missing or PATH not set.","error":"mlogx: command not found"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}