API Stability Notice
Macroforge is under active development. The API is not yet stable and may change between versions. Some documentation sections may be outdated.
Configuration
Macroforge can be configured with a macroforge.config.ts file in your project root.
Configuration File
Macroforge searches for config files in the following order, walking up from the input file's directory:
macroforge.config.tsmacroforge.config.mtsmacroforge.config.jsmacroforge.config.mjsmacroforge.config.cjs
Create a macroforge.config.ts file:
import { defineConfig } from "macroforge/config";
export default defineConfig({
keepDecorators: false,
});Options Reference
allowNativeMacros
| Type | boolean |
| Default | true |
Enable or disable native (Rust) macro packages. Set to false to only allow built-in macros.
macroPackages
| Type | string[] |
| Default | [] |
List of npm packages that provide macros. Macroforge will look for macros in these packages.
{
"macroPackages": [
"@my-org/custom-macros",
"community-macros"
]
}keepDecorators
| Type | boolean |
| Default | false |
Keep @derive decorators in the output. Useful for debugging.
limits
Configure resource limits for macro expansion:
{
"limits": {
// Maximum time for a single macro expansion (ms)
"maxExecutionTimeMs": 5000,
// Maximum memory usage (bytes)
"maxMemoryBytes": 104857600, // 100MB
// Maximum size of generated code (bytes)
"maxOutputSize": 10485760, // 10MB
// Maximum number of diagnostics per file
"maxDiagnostics": 100
}
}Macro Runtime Overrides
Override settings for specific macros:
{
"macroRuntimeOverrides": {
"@my-org/macros": {
"maxExecutionTimeMs": 10000
}
}
}Environment Variables
Some settings can be overridden with environment variables:
| Variable | Description |
|---|---|
MACROFORGE_DEBUG | Enable debug logging |
MACROFORGE_LOG_FILE | Write logs to a file |
MACROFORGE_DEBUG=1 npm run dev