I always wanted to retribute the community for all those packages I use every day, but I couldn’t think of anything useful enough to be shared. For everything we can think of, there’s already at least one good package on NPM!
Fortunately, the opportunity for my contribution came in when I needed a package for dispatching strongly-typed events from one class to another, as in the Observer Pattern.
Well, in fact, there is a brunch of solutions for this already shared on NPM. If we close our eyes and click a random search result, we should be in good hands — there are excellent libs! But what I had in mind was very specific.
Worked like a charm! I was euphoric! So I quickly extracted the code to a new repository and initialized an NPM package. Linked it to my game repository and… voilà! A new package was born!
But wait! Not so fast…
Having a pack of source files is not enough. A decent Readme, a well-defined package.json, minimal examples, and test coverage are the least we expect when looking for a lib on NPM. So, after reading some articles from experienced package maintainers, I did it all and more.
Finally, it was in good shape to be shared on the NPM registry. So I logged in via command line and published it!
Typed Event Dispatcher was live! But now, how to let other devs know about it?
This step is also important for the new package to have a good start. Developers spread the word about their libs through blog posts (Changelog.com, Dev.to, Medium, LinkedIn), social updates (Twitter, Facebook), chats (Slack, Discord), answers on Q&A portals (StackOverflow, Quora), forums, messengers and also in Meetups, Conferences.
Letting people have a glance at the project highlights using badges helps too. For this, Shields.io provides almost everything needed.
Keep in mind that developers are more and more concerned about dependency bloat, so, besides quality and coverage, they value small-size and few-dependencies. Projects like BundlePhobia were born for it and should be used for self-checking.
I hope these thoughts can help those who are giving their first step into NPM publishing.
Have a great journey!