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

Factor out core react-scripts functionality for library scaffolding #423

Closed
taion opened this issue Aug 11, 2016 · 8 comments
Closed

Factor out core react-scripts functionality for library scaffolding #423

taion opened this issue Aug 11, 2016 · 8 comments

Comments

@taion
Copy link

taion commented Aug 11, 2016

cc @ryanflorence @ayrton @gaearon @jquense

This was intended as a dumb Twitter joke about "create-react-lib", but there's actually something to it.

Scaffolding React libraries hits the same point points as scaffolding React apps. However, in one way it's worse – library developers often have multiple library packages.

Getting a minimal library scaffolding up is pretty easy if you've done it a few times, but getting a good library scaffolding is time-consuming if you want to include all of:

  • UMD build (unminified and minified)
  • ES module build
  • Coverage reporting on tests

It's just as difficult to keep stuff from going stale. I think I finally upgraded the last few of my libraries to Babel 6, but I'm not really sure, and it's a fair bit of work every time to make sure I remembered to set everything up appropriately. You can start a project by copying the last thing you did, but it's harder to keep stuff up-to-date.

Given that, it could be quite useful if some of the core functionality in react-scripts could be made reusable in such a way as to offer a "create-react-lib", where the main benefits would be:

  • Reduce the amount of extra work required to get really good tooling set up
  • Just update a dependency to freshen tooling dependencies

I haven't fully thought through how this would work, but I wanted to write this up real quick to lay out the pain points that I hope we can use functionality from here to resolve.

@ayrton
Copy link
Contributor

ayrton commented Aug 11, 2016

I honestly think this idea is genius. Having a standard way to create libraries (designed specifically for react) will only encourage more people to contribute to the react eco system.

Getting started and having to figure out how to set up webpack, babel, builds for the first time is a time consuming job. Having gone through this process a couple times I think a standardised way of doing this would be fantastic. Having the same setup across several projects would also mean more people will be familiar to the setup.

But like you said Jimmy, I think the biggest gain most likely comes from ease of updating dev tool dependencies.

I'm happy to help out, let me know what I can do!

@insin
Copy link
Contributor

insin commented Aug 12, 2016

This is one of the use cases nwb addresses, as I was having the same issue maintaining multiple component projects and keeping all the tooling and config up to date.

+1 for having an official create-react-lib

@insin
Copy link
Contributor

insin commented Sep 2, 2016

Any thoughts on how this would in terms of modules? Should react-scripts gain the ability to scaffold out and provide tooling for a component/library or should there be a new module?

@gaearon
Copy link
Contributor

gaearon commented Sep 2, 2016

I would imagine react-scripts could include more commands, like build-lib etc. We'd want to keep Babel configs the same, for example. But it's very hard to say until somebody makes a proof of concept.

@gaearon
Copy link
Contributor

gaearon commented Sep 30, 2016

We don’t have any immediate plans to build this. If somebody wants to submit a proof of concept, they’re welcome to.

In the meantime we published our Babel preset and even some webpack utilities so it should be easier to build something like this separately. Jest configuration has also vastly simplified in the last couple of releases.

@jikkujose
Copy link

I wonder FB already should be having some solution to tackle this? I really wish to create a component library but the thought of having to set it all up makes me cringe & end up copy pasting the code. Now it has come to the point of becoming a pain.

@nileshgulia1
Copy link

nileshgulia1 commented May 16, 2018

We there at plone intend to make one of our project a react-scripts like library, so that with one command we can generate our boilerplate( we have our own) with the pre-configured tools. So for creating a library like react-scripts , do we use the same configuration settings and project layout as the scripts does ( env, polyfills, webpack )? Any suggestions are welcome.
cc @taion @gaearon @ayrton
Thanks

@antonybudianto
Copy link

I tried to make one:
https://github.com/antonybudianto/react-lib-scripts

Still new though, but works for simple React UI library

@lock lock bot locked and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants