Writing an Open Source JavaScript Library
By Kent C. Dodds
Writing an Open Source JavaScript Library
We’ll get started by giving an overview of what we’re going to build, then we’ll get our blank slate going with a package.json. We’ll talk about the significance of this file and the various properties we’ll use to help us with the distribution and management of our module and its dependencies. Then we’ll add the tooling needed for testing our library and adding code coverage. This is something that’s really important to get working early on in the project, so we’ll get it done early. Then we’ll jump into setting up the tooling for transpiling our source code from ESNext to ES5 so we distribute code that can be consumed by people delivering to older environments (like old Node or browsers). Then we’ll add the tooling we need to distribute a browser version of our library so people can consume our library in the context of a browser (without having to bundle it themselves). As contributions to our library grows, it’ll be important to be able to check that the contribution passes our unit tests automatically without having to pull down every pull request to test it locally. So we’re going to add continuous integration with TravisCI to automatically run our tests and report the code coverage reports to codecov.io With this infrastructure set up, we’ll then add semantic-release to automate releases of our library. This will help us reduce a great amount of human erro