Why is distributing a react component so hard?
I wanted to share my work for others to use (including myself). A simple request right? I remember the days (I'm so old) 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?
4 comments
[ 2.7 ms ] story [ 21.1 ms ] threadYou can also upload your component to the npm, so that other could use it. By adding "react-component" keyowrd to the description on npm, your component should be available at http://react-components.com/.
If you want to use in on the frontend right away, then maybe write it in AMD format, so that you could load it via require.js?
I know I'm being a bit silly silly here but it seems awfully difficult to get started. Too difficult if you ask me. Am I missing something fundamental?
I can certainly get there in the end but there are a lot of configuration tasks to get there.
This is all about modules. It is a good programming practice to turn piece of code that can be used in multiple projects into the module, so that it is easier to load them up in the next project.
You can check node.js docs on the example of modules and how your code should work so: http://nodejs.org/api/modules.html
In node.js it is trivial - just like loading external modules in python (if you ever worked with it).
RequireJS is a tough nut, I give you that. That's mainly because of the asynchronous nature of the script loading on the web. Can't really recommend anything on the topic. I myself spent quite some time before it clicked.