How to bundle a tree-shakable typescript library with tsup and publish with npm

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • webpack-starter

    ✨ A lightweight foundation for your next webpack based frontend project.

    After we transpile with `tsup` all the files will be added to the bundle. Note that we are preserving folder structure under lib. ![Screen Shot 2022-09-08 at 23.40.33.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1662669755836/ce6t5YIdq.png align="left") Let's jump into to the app and locally link the library for testing. I'll use this webpack starter https://github.com/wbkd/webpack-starter ### Testing with npm link The easiest way to test your library is to register it locally with `npm link` or `yarn link`.

  • tsup-library-template

    A template for building a library with tsup 🎆

    In case you want to use this approach as a template 👉 https://github.com/orabazu/tsup-library-template

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

  • swc

    Rust-based platform for the Web

    esbuild claimed to be the fastest in the town when it comes to bundlers, and it seems so according to benchmarks as well. Similar to Parcel, tsup is a zero-config library(in case you don't want it) based on esbuild. Parcel is based on Rust based swc compiler meanwhile esbuild is based on Go. Tsup is tailored to work seamlessly with TS. Even though it is zero config you can change the configs if need be, so we do. Here is the config I used for this article.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts