How to build tree-shakeable JavaScript libraries

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

SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
surveyjs.io
featured
InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
  • Chart.js

    Simple HTML5 Charts using the <canvas> tag

  • In Chart.js, tree-shaking didn’t work as expected because of assignments to class properties (replaced with static properties).

  • chartist

    Simple responsive charts

  • (Full disclosure: this is a real-world design decision from Chartist, an open-source data visualization library I maintain and contribute to.)

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
  • size-limit

    Calculate the real cost to run your JS app or lib to keep good performance. Show error in pull request if the cost exceeds the limit.

  • However, you can use the Size Limit library to control the size of a bundle or individual exports. Here’s an example configuration:

  • terser

    🗜 JavaScript parser, mangler and compressor toolkit for ES6+

  • You can see that the div function was copied “as is” and is not used in any way. When you run Webpack in production mode, it will remove this function. (Internally, Webpack relies on Terser for minification; Rollup performs tree-shaking and dead code elimination on its own.)

  • Rollup

    Next-generation ES module bundler

  • You can see that the div function was copied “as is” and is not used in any way. When you run Webpack in production mode, it will remove this function. (Internally, Webpack relies on Terser for minification; Rollup performs tree-shaking and dead code elimination on its own.)

  • react-chartjs-2

    React components for Chart.js, the most popular charting library

  • In react-chartjs-2, some exported entities are constructed by calling a factory method (marked as pure).

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

  • Good Charting Libraries

    2 projects | /r/react | 17 Apr 2023
  • Data Analytics Made Easy

    2 projects | dev.to | 30 Nov 2022
  • Using Chart.js plugins with webpack

    6 projects | dev.to | 3 Jul 2022
  • Built an app to study businesses - visualize financials, annotate filings &amp; transcripts, and more!

    2 projects | /r/webdev | 2 Jul 2022
  • How to use Google Charts with React

    2 projects | dev.to | 12 May 2022