-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support options to babel-macro #26
Comments
Hey @vinhlh! 👋 I can think of a few ways to do this. Probably the best is to use Alternatively, you could do: import t from 'tagged-translations/macro';
t.config({
// some literal
})
const name = 'Vinh Le';
t`Hello ${name}`; 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 Thanks a bunch! Oh, and don't forget to upgrade to 1.0.0! |
@kentcdodds I respect your decision here, but just wanted to throw in a counterargument for consideration. If the goal of babel-macros is to make macro authoring and usage easier and more standardized, configuration seems to fall into that scope. The proposed solutions introduce some challenges that authors and users would have to confront:
Given those problems, I wonder if configuring macros with the (Another possibility would be to introduce a |
Hmmm... I guess I'm having trouble because I can only think of a handful of situations where configuration is needed... Could you give me some real examples where configuration is necessary? I definitely want to avoid config via babelrc because then it won't work with CRA |
@kentcdodds: Interesting, because I'm having trouble thinking of macros that I wouldn't want configuration for. I guess the
|
Thanks @davidtheclark! I think that I'm warming up to it. I think that @threepointone also has some thoughts as well. |
I'm going to reopen this... We'll probably do something to make config easier. |
I think that I want to go with the
The biggest problem with the So for that reason, I think that My first impression is to do this: const {create: createMacro} = require('babel-macros')
const configName = 'taggedTranslations'
module.exports = createMacro(myMacro, {configName})
function myMacro({references, state, babel, config}) {
// config would be taggedTranslations portion of the config as loaded from `cosmiconfig`
} The config would be called
With the way that I'm going to start working on this until my wife gets home or the kids wake up. Please ping me here if you have issues, ideas, or comments. |
Got a WIP: #36 |
Please review :) |
Ok, the PR is ready. I want at least one review before I merge it. |
Problem
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.
The text was updated successfully, but these errors were encountered: