Support options to babel-macro
See original GitHub issueProblem
import t from 'tagged-translations/macro';
const name = 'Vinh Le';
t`Hello ${name}`;
This is my use case that I need to have some configurations. It could be the location of the translation file.
The current version has no way to do this. We might need to configure these options globally.
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (8 by maintainers)
Top Results From Across the Web
Zero-config code transformation with babel-plugin-macros
Introducing babel-plugin-macros. Guess what! A tool like this exists! babel-plugin-macros is a new Babel plugin that allows you to do exactly ...
Read more >Babel macros | Tan Li Hau
In this article, I am going to talk about Babel macros. ... Meaning the support that a new developer to the team can...
Read more >How to use the babel-plugin-macros.createMacro function in ...
To help you get started, we've selected a few babel-plugin-macros.createMacro examples, based on popular ways it is used in public projects.
Read more >How to use Babel macros with React Native - freeCodeCamp
Now, along with the polyfill, I also needed to import all the supporting locale files. There are two options here: Load all the...
Read more >babel-macros - npm
babel -macros has been renamed to babel-plugin-macros. Please use that package instead. babel-macros. 2.0.0 • Public ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey @vinhlh! 👋
I can think of a few ways to do this.
Probably the best is to use
cosmiconfig
and in your plugin you search for the relevant config based on the file (which you can find from thestate
object. I think that would be pretty straightforward.Alternatively, you could do:
And you could use it in your macro as well. That’s what I had in mind for some sort of config solution.
I don’t think that I want to expose a way to configure individual macros via the
babel-macros
config in.babelrc
because that could get unwieldy. I think my suggestion is a pretty good solution. So I’ll go ahead and close it. But feel free to continue dialog and if we decide thatbabel-macros
could do something better to support this use case then we can reopen the issue.Thanks a bunch!
Oh, and don’t forget to upgrade to 1.0.0!
Ok, the PR is ready. I want at least one review before I merge it.