react-webpack-generators / generator-react-webpack

Yeoman generator for ReactJS and Webpack
http://newtriks.com/2013/12/31/automating-react-with-yeoman-and-grunt/
MIT License
2.87k stars 356 forks source link

Relay #175

Closed stylesuxx closed 8 years ago

stylesuxx commented 8 years ago

Hey @weblogixx, I just wanted to ask what your stand on Relay is.

To give some context: I am building myself a stack which looks like this:

I saw your https://github.com/weblogixx/generator-react-webpack-alt which I wanted to use as a "template" to adapt it to redux.

One of the next steps for me is to get the relay and redux parts up and running, and I was wondering what your stand is on this. Is the relay part something I could add to this generator or would this be something I better place in my "top level" redux generator?

My ultimate goal is then to have a generator like this:

generator-my-full-stack-opinion
  generator-my-front-stack-optinion
    generator-react-webpack-redux
      generator-react-webpack
  generator-my-backend-stack-opinion
      generator-es6-graphql

I would appreciate some feedback on this.

Ps.: Also summoning @sthzg for his opinion/feedback on generator composition.

weblogixx commented 8 years ago

Hi @stylesuxx,

currently you would have to build it the way you describe it (at least roughly):

Currently, the call methods for yeoman scripts do allow to use other generators, but you will have to mimic the filesystem layout (e.g., generator-react-webpack-alt does not extend generator-react-webpack, but for all of generator-react-webpacks options, I have to create dummy folders). Thats unfortunate, but currently there seems no official alternative that I see.

I have not had a deeper look into relay. As it currently states, I think it would be best to first include it in your own generator. If there are more people wanting this, maybe, with your permission, we could roll it out in generator-react-webpack?

@sthzg did try to fix this with his own implementation, but it was a little hacky (altough, I think it was a good piece of work and this feature _is_ one that I really miss in yeoman). Maybe something like this should be contributed to yeoman directly?

sthzg commented 8 years ago

a little hacky ... is a nice understatement :) I realized that going down that route means eventually rebuilding parts of NPM (a registry, a config format, a network layer for downloading/updating, declaration of compatibility). Of course that makes no sense, so it should either be built on APIs available from NPM or as @weblogixx says directly into Yeoman. The feature on Yeoman is open to PRs https://github.com/yeoman/generator/issues/867.

Maybe the biggest problem with subgen-composition that I see right now is that the only easy thing to achieve is plugging your standalone-subgens into a foreign generator. Once there is composition between them I think it can't work well because of maintainability.

As soon as logic is not maintained within one umbrella-project (with an umbrella-test-suite) any update of the host-generator might break composed features in 3rd-party subgens (if these 3rd-party-subgens modify syntax in the core/other subgens in any way it could even damage the project).

The way that Yo handles composition right now prevents this, but it comes at a high cost (in context of the particular use case, not in general). Update: Also I don't know Yeoman well enough to say how much infrastructure for implementing that use case is already there and how well it is suited.

That said, I think that solving that problem would enable interesting features in the world of starter-kits / boilerplates. Because more often than not you want to change at least one or two components of an otherwise perfect starter kit. And it's not all that difficult to do, but it's that kind of thing that you have to do anytime you start a new project (and to coordinate with updates from the original starter kit).

weblogixx commented 8 years ago

I think so, too. However while we have no official support for such a feature, we would still have to do it the way it is done in the alt version I think.

@stylesuxx: Please tell me when you start with your work, would be interested in something like this, too. On the redux part, just tell me when you are ready and I will add a link to the README.

stylesuxx commented 8 years ago

This is some good food for thoughts, thank you guys. I will need to break this down in a small test setup, somehow I feel I am still missing a piece to fully understand the problem :-/

@weblogixx I will keep you updated, maybe you can leave this issue open for further discussion.

weblogixx commented 8 years ago

@stylesuxx, yes, lets do it like that. Just have a look at generator-react-webpack-alt (the name is waaaay to long :() to see how it is done in the "yeoman way". That means you will need to add some (more or less) useless directories.

However, if you find another way to make things smoother for dependent generators, please contact me and I will happily follow them.

weblogixx commented 8 years ago

@stylesuxx: I will close this issue, as the question itself has nothing to do with the generator itself. If you need more input, do not hesitate to open a new issue.