Skip to content
PluginStats

babel-plugin-macros weekly downloads statistics

By kentcdodds (2 listings) · npm · Babel plugins

Allows you to build compile-time libraries

View on npm Fresh · Oct 17, 2026

babel-plugin-macros has 15,125,170 recorded weekly downloads on npm, a decrease of 46.9% over the past 30 days.

It ranks #103 of 2,256 tracked npm listings by weekly downloads.

Over 90 days, weekly downloads changed by -49.0%.

PluginStats has 121 daily observations since Jun 19, 2026; the latest is from Oct 17, 2026.

Weekly downloads
15,125,170
Official API · Oct 17, 2026
7-day growth
-53.4%
-17.3M weekly downloads
30-day growth
-46.9%
-13.4M weekly downloads
90-day growth
-49.0%
-14.5M weekly downloads
Rank
#103
Among tracked npm listings

About babel-plugin-macros

babel-plugin-macros 🎣

Allows you to build simple compile-time libraries

[![Build Status][build-badge]][build] [![Code Coverage][coverage-badge]][coverage] [![version][version-badge]][package] [![downloads][downloads-badge]][npmtrends] [![MIT License][license-badge]][license] [![All Contributors][all-contributors-badge]](#contributors-) [![PRs Welcome][prs-badge]][prs] [![Code of Conduct][coc-badge]][coc]

The problem

Check out this guest post on the Babel.js blog for a complete write up on the problem, motivation, and solution.

Currently, each babel plugin in the babel ecosystem requires that you configure it individually. This is fine for things like language features, but can be frustrating overhead for libraries that allow for compile-time code transformation as an optimization.

This solution

babel-plugin-macros defines a standard interface for libraries that want to use compile-time code transformation without requiring the user to add a babel plugin to their build system (other than babel-plugin-macros, which is ideally already in place).

Expand for more details on the motivation

For instance, many css-in-js libraries have a css tagged template string function:

The function compiles your css into (for example) an object with generated class names for each of the classes you defined in your css:

This class name can be generated at runtime (in the browser), but this has some disadvantages:

• There is cpu usage/time overhead; the client needs to run the code to generate these classes every time the page loads • There is code bundle size overhead; the client needs to receive a CSS parser in order to generate these class names, and shipping this makes the amount of js the client needs to parse larger.

To help solve those issues, many css-in-js libraries write their own babel plugin that generates the class names at compile-time instead of runtime:

If the css-in-js library supported babel-plugin-macros instead, then they wouldn't need their own babel plugin to compile these out; they could instead rely on babel-plugin-macros to do it for them. So if a user already had babel-plugin-macros installed and configured with babel, then they wouldn't need to change their babel configuration to get the compile-time benefits of the library. This would be most useful if the boilerplate they were using came with babel-plugin-macros out of the box, which is true for [create-react-app][cra].

Although css-in-js is the most common example, there are lots of other things you could use babel-plugin-macros for, like:

• Compiling GraphQL fragments into objects so that the client doesn't need a GraphQL parser • Eval-ing out code at compile time that will be baked into the runtime code, for instance to get a list of directories in the filesystem (see [preval][preval])

Table of Contents

• Installation • Usage • User docs • Author docs • Caveats • FAQ • How do I find available macros? • What's the difference between babel plugins and macros? • In what order are macros executed? • Does it work with function calls only? • How about implicit optimizations at compile time? • Inspiration • Other Solutions • Issues • 🐛 Bugs • 💡 Feature Requests • Contributors ✨ • LICENSE

Installation

This module is distributed via [npm][npm] which is bundled with [node][node] and should be installed as one of your project's devDependencies:

Usage

You may like to watch this YouTube video to get an idea of what macros is and how it can be used.

User docs

Are you trying to use babel-plugin-macros? Go to other/docs/user.md.

Author docs

Are you trying to make your own macros that works with babel-plugin-macros? Go to other/docs/author.md. (you should probably read the user docs too).

Caveats

Babel cache problem

Note: This issue is not present when used in Create React App.

Most of the time you'll probably be using this with the babel cache enabled in webpack to rebuild faster. If your macro function is not pure which gets different output with same code (e.g., IO side effects) it will cause recompile mechanism fail. Unfortunately you'll also experience this problem while developing your macro as well. If there's not a change to the source code that's being transpiled, then babel will use the cache rather than running your macro again.

For now, to force recompile the code you can simply add a cache busting comment in the file:

This problem is still being worked on and is not unique to babel-plugin-macros. For more details and workarounds, please check related issues below:

• babel-plugin-preval: How to force recompile? #19 • graphql.macro: Recompile problem (babel cache) #6 • twin.macro: Can't change taliwind config #37

FAQ

How do I find available macros?

You can write your own without publishing them to npm, but if you'd like to see existing macros you can add to your project, then take a look at the Awesome babel macros repository.

Please add any you don't see listed!

What's the difference between babel plugins and macros?

Let's use babel-plugin-console as an example.

If we used babel-plugin-console, it would look like this:

1. Add babel-plugin-console to .babelrc 2. Use it in a code:

When that code is run, the scope function does some pretty nifty things:

Browser:

Node:

Instead, let's use the macro it's shipped with like this:

1. Add babel-plugin-macros to .babelrc (only once for all macros) 2. Use it in a code:

The result is exactly the same, but this approach has a few advantages:

Advantages:…

Description from the npm listing.

  • babel-plugin
  • macros
  • macro
  • babel-macro
  • babel-plugin-macro
  • babel-macros
  • babel-plugin-macros

Where babel-plugin-macros sits in the listing

Each band is one page of 20. Weekly downloads on a log scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.

All npm2,256 listings · 113 pages · page 6, #3 (overall #103)
All npm: every listing in weekly downloads order
PNG SVG
Babel plugins251 listings · 13 pages · page 5, #8 (overall #88)
Babel plugins: every listing in weekly downloads order
PNG SVG

Charts

Images: 30d · 1y · all time · 1600×900 dark

Adoption over time

babel-plugin-macros weekly downloads on npm, last 90 days: 15,125,170 weekly downloads as of Oct 17, 2026, -49.0% over 90 days.babel-plugin-macrosWeekly downloads on npm · Last 90 days15,125,170downloads / week-49.0% over 90 days15M20M25M30M35M40MJul 19Aug 3Aug 18Sep 2Sep 17Oct 2Oct 17downloads / weekobservedarchived (Internet Archive)no observationsJul 21, 2026 – Oct 17, 2026 · 89 observations · Updated Oc…pluginstats.com
babel-plugin-macros weekly downloads on npm, last 90 days: 15,125,170 weekly downloads as of Oct 17, 2026, -49.0% over 90 days.
PNG SVG

7/30/90-day growth

babel-plugin-macros weekly downloads growth on npm: -53.4% over 7 days, -46.9% over 30 days, -49.0% over 90 days.babel-plugin-macrosWeekly downloads growth on npm15,125,170downloads / week now7-day growth-17,343,814 weekly downl…-53.4%30-day growth-13,365,340 weekly downl…-46.9%90-day growth-14,523,322 weekly downl…-49.0%Growth vs. nearest observation to each baseline date · Updated Oct 17, 2026pluginstats.com
babel-plugin-macros weekly downloads growth on npm: -53.4% over 7 days, -46.9% over 30 days, -49.0% over 90 days.
PNG SVG

Ranking history

babel-plugin-macros npm ranking history: currently #103 (by weekly downloads).babel-plugin-macrosnpm ranking · by weekly downloads · Last 90 days#103current rank#101#102#103#104#105Jul 21Aug 5Aug 20Sep 4Sep 19Oct 4Oct 19rankOct 18, 2026 – Oct 19, 2026 · 2 observations · Updated Oct 17, 2026pluginstats.com
babel-plugin-macros npm ranking history: currently #103 (by weekly downloads).
PNG SVG

Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.

Recent observations

Full history (121)
Recent weekly downloads observations for babel-plugin-macros
Date (UTC)Weekly downloadsChange vs. previous
15,125,170-2.5M
17,644,209+119.1K
17,525,123-7.4M
24,933,868-7.4M
32,299,3960
32,299,396-358.1K
32,657,505+188.5K
32,468,984+196.7K
32,272,258+489.2K
31,783,030+329.9K
31,453,120+213.6K
31,239,511-7M
38,277,462-245K
38,522,488—

Similar npm Babel plugins plugins

Data source

Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.

Listing: https://www.npmjs.com/package/babel-plugin-macros. First seen Oct 16, 2026; last successful collection Oct 19, 2026. See the methodology.