Skip to content
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 custom babel configuration #39

Closed
schibrikov opened this issue Oct 30, 2018 · 6 comments
Closed

Support custom babel configuration #39

schibrikov opened this issue Oct 30, 2018 · 6 comments

Comments

@schibrikov
Copy link
Contributor

A lot of people are using various proposal plugins for babel. react-gettext-parser is unable to parse files using some additional syntax.
We need to just add more plugins to .babelrc to support common cases or, more preferably add support for custom configuration.

@schibrikov schibrikov changed the title Support configuration of babel plugins Support custom babel configuration Oct 30, 2018
@alexanderwallin
Copy link
Collaborator

Yes, this would make perfect sense. Ideally, react-gettext-parser would just pick up whatever Babel configuration is available.

@schibrikov
Copy link
Contributor Author

@alexanderwallin can we just add some proposal plugins for now, so I can start using this tool, and then start working on auto picking up project's .babelrc?
It fails on parsing "export default from" and maybe "export * from" for now.

@alexanderwallin
Copy link
Collaborator

If that's easy to setup, then sure. Would you be able to submit a PR?

@schibrikov
Copy link
Contributor Author

Yes, of course. I'll try when I get some time.

@schibrikov
Copy link
Contributor Author

schibrikov commented Nov 23, 2018

Finally I found some time to make a PR. Now it is possible to parse my entire project.

I made a quick research about picking up external babelrc:
The thing is .babelrc and this plugins list are 2 different kind of things. Here we specify plugins used for parsing (for understand syntax), but in .babelrc files we see a list of transformations that will be applied, not a list of used syntactic constructions.

For example those users who support only latest browsers (chrome canary) can leave this list empty at all. And if we'll make a list of plugins according to .babelrc, out parser will not be able to parse code at all.

The same issue exists in babel-eslint project (babel/babel-eslint#573).
Seems like it is not being solved for almost a year. But looks like they have added an option to specify extra plugins used alongside with predefined.

@alexanderwallin
Copy link
Collaborator

Thanks for the PR and clarification! Let's just keep it static for now, then. If things break, people can report it and we'll have another look.

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

No branches or pull requests

2 participants