Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support for babel-plugin-react-intl-auto #7

Closed
jdcrensh opened this issue Feb 8, 2018 · 6 comments
Closed

Support for babel-plugin-react-intl-auto #7

jdcrensh opened this issue Feb 8, 2018 · 6 comments

Comments

@jdcrensh
Copy link
Contributor

jdcrensh commented Feb 8, 2018

It would be great if this tool supported babel-plugin-react-intl-auto. It allows ids to be autogenerated based on the file's path.

I installed the plugin and added it to my .babelrc, but it doesn't look like riw is picking up the plugin.

.babelrc

{
  "presets": ["react-app"],
  "plugins": [
    ["react-intl-auto", {
      "removePrefix": "src/",
      "filebase": false
    }]
  ]
}

I dug in a little bit, and it looks like riw uses babel-plugin-react-intl explicitly:

plugins: [pluginReactIntl],

Would it be possible to include additional babel plugins, or am I missing something?

@avaragado
Copy link
Owner

Thanks for the report!

You're right, at the moment the code runs a babel transform explicitly using babel-plugin-react-intl. I'm not familiar with babel-plugin-react-intl-auto but it may be possible to get them to play nicely together. If I get a chance in the next couple of days I'll take a look.

@jdcrensh
Copy link
Contributor Author

jdcrensh commented Feb 8, 2018

I was able to add babel-plugin-react-intl-auto to riw without breaking any tests (it has to be run before babel-plugin-react-intl) since it's compatible with the standard defineMessages syntax. However, making the plugin user-configurable through riw.config.js was a little beyond me, since the Config object isn't passed to that function.

@avaragado
Copy link
Owner

Good to know it works! Would you be happy with a riw config setting that defines any extra plugins to run? I'm pretty sure that's doable, once I get my head back into the code.

@jdcrensh
Copy link
Contributor Author

jdcrensh commented Feb 8, 2018

Ideally, it'd be preferable if the plugin was blackboxed just as babel-plugin-react-intl is, since there'd be no other use for it other than passing off to riw. We'd rather not have babel dependencies in our create-react-app apps 😉

Maybe it could default the config as reactIntlAuto: { removePrefix: 'src', filebase: false }, or not use the plugin if false?

@avaragado
Copy link
Owner

@jdcrensh Released in 0.7.0.

@jdcrensh
Copy link
Contributor Author

jdcrensh commented Feb 9, 2018

You're awesome @avaragado! Updated and it's working great 👍

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants