How to build tree-shakeable JavaScript libraries

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

CodeRabbit: AI Code Reviews for Developers
Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.
coderabbit.ai
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  1. 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).

  2. CodeRabbit

    CodeRabbit: AI Code Reviews for Developers. Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.

    CodeRabbit logo
  3. 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.)

  4. 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:

  5. 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.)

  6. 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.)

  7. 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

Did you know that JavaScript is
the 3rd most popular programming language
based on number of references?