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

add support for babel-macros #1968

Closed
kentcdodds opened this issue Jul 16, 2017 · 8 comments
Closed

add support for babel-macros #1968

kentcdodds opened this issue Jul 16, 2017 · 8 comments

Comments

@kentcdodds
Copy link

Hi there 👋

I'm helping to investigate ways that create-react-app can use babel plugins like babel-plugin-relay without having to change configuration (see facebook/create-react-app#2730 for more context). This has resulted in the creation of babel-macros. With babel-macros, users can install and configure this plugin and have access to use any macro available (or create their own) without configuring anything else. This is appealing to create-react-app users because so far they've had to eject if they wanted to use something like preval, emotion, or the babel plugin for relay.

Adding support should be pretty simple (mostly a slight extracting refactor around here to allow code sharing between the plugin and macro) and starting out with experimental support would be totally fine considering we face a catch 22 situation (CRA wants to see usage of babel-macros in the community before adopting it and you all probably feel the same).

What do you all think?

@gaearon
Copy link
Contributor

gaearon commented Jul 16, 2017

cc @josephsavona if you're still interested :-)

@kassens
Copy link
Member

kassens commented Sep 11, 2017

I'm not very familiar with create-react-app, if someone want's to publicise something or work on a create-relay-app example, feel free to open a PR or publish a new repo

@kassens kassens closed this as completed Sep 11, 2017
@gaearon
Copy link
Contributor

gaearon commented Sep 11, 2017

I don’t think this issue is about creating an example. It’s about supporting this: http://babeljs.io/blog/#zero-config-code-transformation-with-babel-macros

@kentcdodds
Copy link
Author

That's correct. The idea is that hopefully if we get a babel-macros export as part of this package, then CRA could add babel-macros to the babel config and folks using create-react-app would be able to use relay without having to configure babel at all. That'd be a significant win IMO :)

@kassens
Copy link
Member

kassens commented Sep 11, 2017

Re-opening for now as there's clearly interest and potential value.

Trying to understand what this would involve. We could move the babel transform into the babel-macro framework, all the babel-plugin-relay does for Relay Modern is (pretty much) to replace

// input
graphql`fragment MyFragment on SomeType { ... }`
// output
require('./__generated__/MyFragment.graphql')

But we would still need to run the relay compiler to generate the files. I guess users of CRA could still install the relay-compiler to generate these files?

@kentcdodds
Copy link
Author

But we would still need to run the relay compiler to generate the files. I guess users of CRA could still install the relay-compiler to generate these files?

I think that should work. I don't know relay very well though. How does it normally integrate with webpack projects? Do folks normally have two scripts running? One for webpack and the other for the relay-compiler?

@kassens
Copy link
Member

kassens commented Sep 11, 2017

Yes or a build process that invokes both of them sequentially / in watch mode.

@gaearon
Copy link
Contributor

gaearon commented Sep 11, 2017

That sounds reasonable to me!

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

Successfully merging a pull request may close this issue.

3 participants