The last time I wanted to publish a npm package was in 2018. It was a React library which provided Components for creating Forms. It wasn’t straight forward to publish such a library back then. There were so many things to handle on your own, especially when it came to TypeScript.

Assuming you were already familiar with webpack you thought: ha that should be easy, I can leverage my knowledge and just bundle my library with webpack, exactly like my webapps. But then you suddenly heard of that new kid on the block: Rollup, which seems to do a better job at bundling libraries. So a new bundler you had to learn and still soo many things to take care of on your own.

Great that we’re now fast forwarded to 2021. There’s a new player in the town to make our lives a lot easier. Let me introduce you to  tsdx.io

The zero-config CLI for TypeScript package development

The goal of TSDX is to get rid of all the pain points I’ve mentioned above and just let you focus on developing your next library, instead of “waste another afternoon on the configuration”. And oh boy, they did an excellent job with this. Actually I couldn’t find the meaning of the TSDX acronym, but I would assume that it stands for TypeScript Developer Experience — which it definitely enhances a lot.

TSDX comes with Rollup under the hood and serves you best-practices for developing and bundling modern NPM packages. It is well tested and the team behind TSDX is  formium, who are also developing the popular React forms library formik, which also leverages the power of TSDX.

The best practices which come with TSDX are should be perfect for the most projects. And even if you need to do adjustments, the process is pretty straight forward. For example for  our library we wanted to use less instead of writing plain css and I show you later how you can adjust the TSDX config to your needs.

#javascript #typescript #programming #npm

Publishing A TypeScript Library in 2021
1.70 GEEK