vite-plugin-macro (v0.2.0) brings macro capabilities to Vite-based projects, allowing developers to write compile-time transformations using Babel macros. It integrates seamlessly with Vite's plugin system, enabling deferred execution, context-aware transformations, and enhanced code generation. Unlike Babel standalone approaches, this plugin is optimized for Vite's build pipeline and supports TypeScript. Due to its early stage (0.x), backward compatibility is not guaranteed. Release cadence is irregular as the project evolves. Key differentiators: Vite-native macro system with Babel under the hood, TypeScript support, and lightweight integration.
npm install vite-plugin-macroNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates setting up vite-plugin-macro in a Vite config and defining a simple macro.
Pin Vite to ^2 or wait for compatible update.
Install @babel/core as a dev dependency.
Replace 'transform' with 'defineMacro' API.
Run 'npm install vite-plugin-macro' and verify import path.
Use default import: import vitePluginMacro from 'vite-plugin-macro'