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 · Dec 6, 2026

babel-plugin-macros has 47,158,268 recorded weekly downloads on npm, an increase of 10.7% over the past 30 days, ranking #99 of 3,247 tracked listings.

Weekly downloads
47,158,268
Official API · Dec 5, 2026
7-day growth
+13.8%
+5.7M weekly downloads
30-day growth
+10.7%
+4.6M weekly downloads
90-day growth
+71.1%
+19.6M weekly downloads
Rank
#99
▲ 2 in 7 days

About babel-plugin-macros

<div align="center"> <h1>babel-plugin-macros 🎣</h1> <p>Allows you to build simple compile-time libraries</p> </div>
<!-- prettier-ignore-start -->

[![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] [![PRs Welcome][prs-badge]][prs] [![Code of Conduct][coc-badge]][coc]

<!-- prettier-ignore-end -->

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

<details> <summary>Expand for more details on the motivation</summary>

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

const styles = css`
  .red {
    color: red;
  }
`

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

console.log(styles) // { red: "1f-d34j8rn43y587t" }

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:

// Before running through babel:
const styles = css`
  .red {
    color: red;
  }
`
// After running through babel, with the library-specific plugin:
const styles = {red: '1f-d34j8rn43y587t'}

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])
</details>

Table of Contents

<!-- START doctoc generated TOC please keep comment here to allow auto update --> <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> <!-- END doctoc generated TOC please keep comment here to allow auto update -->

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:

npm install --save-dev babel-plugin-macros

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:

import macro from 'non-pure.macro';…

Description from the npm listing.

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

README badge

Show your rank in a README or on your website. The badge updates automatically.

Charts

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

Adoption over time

babel-plugin-macros weekly downloads on npm, last 90 days: 47,158,268 weekly downloads as of Dec 5, 2026, +71.1% over 90 days.babel-plugin-macrosWeekly downloads on npm · Last 90 days47,158,268downloads / week+71.1% over 90 days010M20M30M40M50MSep 6Sep 21Oct 6Oct 21Nov 5Nov 20Dec 5downloads / weekobservedarchived (Internet Archive)no observationsSep 7, 2026 – Dec 5, 2026 · 90 observations · Updated Dec …pluginstats.com
babel-plugin-macros weekly downloads on npm, last 90 days: 47,158,268 weekly downloads as of Dec 5, 2026, +71.1% over 90 days.

7/30/90-day growth

babel-plugin-macros weekly downloads growth on npm: +13.8% over 7 days, +10.7% over 30 days, +71.1% over 90 days.babel-plugin-macrosWeekly downloads growth on npm47,158,268downloads / week now7-day growth+5,715,097 weekly downlo…+13.8%30-day growth+4,567,013 weekly downlo…+10.7%90-day growth+19,601,457 weekly downl…+71.1%Growth vs. nearest observation to each baseline date · Updated Dec 5, 2026pluginstats.com
babel-plugin-macros weekly downloads growth on npm: +13.8% over 7 days, +10.7% over 30 days, +71.1% over 90 days.

Ranking history

babel-plugin-macros npm ranking history: currently #99 (by weekly downloads).babel-plugin-macrosnpm ranking · by weekly downloads · Last 90 days#99current rank#94#96#98#100#102#104#106#108Sep 7Sep 22Oct 7Oct 22Nov 6Nov 21Dec 6rankOct 18, 2026 – Dec 6, 2026 · 44 observations · Updated Dec 5, 2026pluginstats.com
babel-plugin-macros npm ranking history: currently #99 (by weekly downloads).

Listing placement

All npm3,247 listings · 163 pages · 1,084 shown · page 5, #19 (overall #99)
All npm: every listing in weekly downloads order

Listing placement

Babel plugins263 listings · 14 pages · page 5, #7 (overall #87)
Babel plugins: every listing in weekly downloads order

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.

Each band is one page of 20. Weekly downloads on a linear 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.

Recent observations

Full history (170)
Recent weekly downloads observations for babel-plugin-macros
Date (UTC)Weekly downloadsChange vs. previous
47,158,268+423.6K
46,734,666+1.9M
44,832,922+1.9M
42,954,742+790.3K
42,164,428+604.3K
41,560,117+154.2K
41,405,935-37.2K
41,443,171-326.4K
41,769,554-1.5M
43,244,810-1.6M
44,822,575-681.6K
45,504,144-135.6K
45,639,752-125.6K
45,765,348—

Similar npm Babel plugins plugins

All 20 babel-plugin-macros alternatives

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 Dec 6, 2026. See the methodology.