Why is distributing a react component so hard?

over 8 years ago from , Developer

Things were so swell. I built a react.js component, I was so chuffed. I even put a gif on the read me. I wanted to share my work for others to use (including myself). A simple request right? I remember the days when I could make a jQuery plugin, and use it in my project by adding a script tag. It was easy.

We seem to have believe now that those methods are a childish way to build a project. You should use a JS tooling system in order to concat, minify, transpile, compile and require. Oh and configure. Configure, configure, configure.

I've spent more time working with these tool chain than working on my component. It shouldn't be like that.

Why is it harder now to share code than when jQuery plugins were popular? Shouldn't it be easier now than ever?

I don't have answers - I'm simply good at complaining! But I can clearly see that without a simple and easy way to share and use code we are being inefficient. I'm a programmer. I don't like being inefficient.

So please, I beg of you, don't make me spend hours lurking on irc channels, nagging for answers or rummaging through github projects in order for me to share my work! Instead enlighten me with an answer to this small question - how can I distribute my component?


  • Clinton HalpinClinton Halpin, over 8 years ago

    Have you tried building out a template for starting out projects? I've found that is one good way to decrease the amount of time it takes to get started. Having a repo you can clone that has Livereload, Minification, CSS preprocessor and a good way to split up JS files is all you'd really need.

    To be real, I don't know the answer to your question. I would tend to agree that there are too many things you need to config in order to start a project.

    You might appreciate this tweet :) - https://twitter.com/ddprrt/status/529909875347030016

    2 points
  • Juha LindstedtJuha Lindstedt, over 8 years ago

    What about NPM?

    2 points
    • Andrew McWattersAndrew McWatters, over 8 years ago

      NPM is great, but what about automatically wiring in your dependencies! And minifying! And concatenating scripts!

      I wonder if there's a grunt or gulp task for getting around to the part where I develop stuff on the web...

      I never in my wildest dreams though I'd ever wait minutes for literally compiling dependencies for a web project.

      These work flows are great and all, but I feel like they're two steps back and one step forward.

      0 points
      • Jack Callister, over 8 years ago

        This is the exact issue. More time spent on config than on building. It's a tough life being a web developer :)

        0 points
    • Jack Callister, over 8 years ago

      NPM is great - but I'm trying to distribute a component with CSS. There doesn't seem to be an easy answer. Even the react material ui kit suggests using an import in your Less files. Which digs directly into the node_modules directory. That solution works but it doesn't feel right.

      0 points
  • Namit ChadhaNamit Chadha, over 8 years ago

    Have you tried webpack?

    It makes consuming React components published via npm incredibly easy.

    Adding script tags (like jQuery plugins) or Polymer components means more requests for the browser - which is why we use JS toolchains.

    0 points
    • Jack Callister, over 8 years ago

      Yes I have indeed tried webpack.

      Does that make a dependency for the user of my component to use webpack too?

      If I am requiring CSS in my JS file and webpack is using a loader to build a bundle then surely the user must have webpack installed too and have the same config.

      The lego brick dream seems so far away.

      0 points