Vite plugin that enables babel-plugin-macros support for using compile-time macros like twin.macro, styled-components/macro, or custom macros in Vite projects. Current stable version is 1.0.6, released infrequently as needed. Key differentiator: it bridges Vite's native ESM handling with babel macros, which Vite doesn't support out of the box. Note: v1.0.6 fixed ESM imports but broke Node <16; the author acknowledged it should have been a major release. Requires Vite >=2 and Node >=16.
npm install vite-plugin-babel-macrosVerified import paths — ran on the pinned version, not inferred.
Shows how to integrate vite-plugin-babel-macros into a Vite config, enabling babel macros like styled-components/macro.
Use import syntax and ensure Node >=16, or pin to v1.0.5 if you need CJS.
Upgrade to Node >=16, or stay on v1.0.5 if you must use older Node.
Use import macrosPlugin from 'vite-plugin-babel-macros'
None
Switch to import syntax and set type:module or use .mjs extension.
Use import macrosPlugin from 'vite-plugin-babel-macros' (no curly braces).
Install babel-plugin-macros: npm install --dev babel-plugin-macros
Reinstall the package: npm install vite-plugin-babel-macros