Handle function calls like `defineConfig()`
mainMagicast allows you to easily manipulate arguments passed to function calls. When a module export is a function call (e.g., export default defineConfig({ ... })), you can access the arguments via the $args property and check the $type property.
import { parseModule, generateCode } from "magicast";
const mod = parseModule(`export default defineConfig({ foo: 'bar' })`);
// Support for both bare object export and `defineConfig` wrapper
const options =
mod.exports.default.$type === "function-call"
? mod.exports.default.$args[0]
: mod.exports.default;
console.log(options.foo); // bar