load_config

Function load_config 

Source
pub fn load_config(
    content: String,
    filepath: String,
) -> Result<LoadConfigResult>
Expand description

Load and parse a macroforge configuration file.

Parses a macroforge.config.js/ts file and caches the result for use during macro expansion. The configuration includes both simple settings (like keepDecorators) and foreign type handlers.

§Arguments

  • content - The raw content of the configuration file
  • filepath - Path to the configuration file (used to determine syntax and as cache key)

§Returns

A LoadConfigResult containing the parsed configuration summary.

§Example

import { loadConfig, expandSync } from 'macroforge';
import fs from 'fs';

const configPath = 'macroforge.config.js';
const configContent = fs.readFileSync(configPath, 'utf-8');

// Load and cache the configuration
const result = loadConfig(configContent, configPath);
console.log(`Loaded config with ${result.foreignTypeCount} foreign types`);

// The config is now cached and will be used by expandSync
const expanded = expandSync(code, filepath, { configPath });