Twin.macro: Add support for using this as a global Babel plugin

Created on 9 Dec 2020  路  1Comment  路  Source: ben-rogerson/twin.macro

It would be really awesome to be able to add this to the Babel configuration (if we can control it) globally as a plugin. That would allow one to use e.g. the tw prop on JSX Element without having to import "twin.macro" everywhere 馃憤

Not sure how hard that would be to abstract so feel free to close this if a macro is _very_ different from a plugin.

Most helpful comment

The way I understand it, babel-plugins visit the entire document while babel-plugin-macros visit specific nodes.

At the moment the tw prop part of twin already functions like a babel-plugin _within_ the babel-macro so I'd probably need to adjust that function to allow interop with an external babel-plugin-twin.

I'll have a better look into this and report back.

>All comments

The way I understand it, babel-plugins visit the entire document while babel-plugin-macros visit specific nodes.

At the moment the tw prop part of twin already functions like a babel-plugin _within_ the babel-macro so I'd probably need to adjust that function to allow interop with an external babel-plugin-twin.

I'll have a better look into this and report back.

Was this page helpful?
0 / 5 - 0 ratings