Skip to content
PluginStats

babel-plugin-preval weekly downloads statistics

By kentcdodds (2 listings) · npm · Babel plugins

Pre-evaluate code at build-time

View on npm Fresh · Dec 6, 2026

babel-plugin-preval has 82,629 recorded weekly downloads on npm, an increase of 7.7% over the past 30 days, ranking #668 of 3,247 tracked listings.

Weekly downloads
82,629
Official API · Dec 5, 2026
7-day growth
-0.5%
-375 weekly downloads
30-day growth
+7.7%
+5.9K weekly downloads
90-day growth
+42.9%
+24.8K weekly downloads
Rank
#668
▼ 14 in 7 days

About babel-plugin-preval

<div align="center"> <h1>babel-plugin-preval</h1> <p>Pre-evaluate code at build-time</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-BADGE:START - Do not remove or modify this section -->

All Contributors

<!-- ALL-CONTRIBUTORS-BADGE:END -->

[![PRs Welcome][prs-badge]][prs] [![Code of Conduct][coc-badge]][coc] [![Babel Macro][macros-badge]][babel-plugin-macros] [![Examples][examples-badge]][examples]

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

The problem

You need to do some dynamic stuff, but don't want to do it at runtime. Or maybe you want to do stuff like read the filesystem to get a list of files and you can't do that in the browser.

This solution

This allows you to specify some code that runs in Node and whatever you module.exports in there will be swapped. For example:

const x = preval`module.exports = 1`

//      ↓ ↓ ↓ ↓ ↓ ↓

const x = 1

Or, more interestingly:

const x = preval`
  const fs = require('fs')
  const val = fs.readFileSync(__dirname + '/fixture1.md', 'utf8')
  module.exports = {
    val,
    getSplit: function(splitDelimiter) {
      return x.val.split(splitDelimiter)
    }
  }
`

//      ↓ ↓ ↓ ↓ ↓ ↓

const x = {
  val: '# fixture\n\nThis is some file thing...\n',
  getSplit: function getSplit(splitDelimiter) {
    return x.val.split(splitDelimiter)
  },
}

There's also preval.require('./something') and import x from /* preval */ './something' (which can both take some arguments) or add // @preval comment at the top of a file.

See more below.

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

Usage

Important notes:

  1. All code run by preval is not run in a sandboxed environment
  2. All code must run synchronously.
  3. Code that is run by preval is not transpiled so it must run natively in the version of node you're running. (cannot use es modules).

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

Template Tag

Before:

const greeting = preval`
  const fs = require('fs')
  module.exports = fs.readFileSync(require.resolve('./greeting.txt'), 'utf8')
`

After (assuming greeting.txt contains the text: "Hello world!"):

const greeting = 'Hello world!'

preval can also handle some simple dynamic values as well:

Before:

const name = 'Bob Hope'
const person = preval`
  const [first, last] = require('./name-splitter')(${name})
  module.exports = {first, last}
`

After (assuming ./name-splitter is a function that splits a name into first/last):

const name = 'Bob Hope'
const person = {first: 'Bob', last: 'Hope'}
import comment

Before:

import fileList from /* preval */ './get-list-of-files'

After (depending on what ./get-list-of-files does, it might be something like):

const fileList = ['file1.md', 'file2.md', 'file3.md', 'file4.md']

You can also provide arguments which themselves are prevaled!

Before:

import fileList from /* preval(3) */ './get-list-of-files'

After (assuming ./get-list-of-files accepts an argument limiting how many files are retrieved:

const fileList = ['file1.md', 'file2.md', 'file3.md']
preval.require

Before:

const fileLastModifiedDate = preval.require('./get-last-modified-date')

After:

const fileLastModifiedDate = '2017-07-05'

And you can provide some simple dynamic arguments as well:

Before:

const fileLastModifiedDate = preval.require(
  './get-last-modified-date',
  '../../some-other-file.js',
)

After:

const fileLastModifiedDate = '2017-07-04'
preval file comment (// @preval)

Using the preval file comment will update a whole file to be evaluated down to an export.

Whereas the above usages (assignment/import/require) will only preval the scope of the assignment or file being imported.

Before:

// @preval

const id = require('./path/identity')
const one = require('./path/one')…

Description from the npm listing.

  • babel
  • babel-plugin
  • eval
  • precompile
  • 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-preval weekly downloads on npm, last 90 days: 82,629 weekly downloads as of Dec 5, 2026, +42.9% over 90 days.babel-plugin-prevalWeekly downloads on npm · Last 90 days82,629downloads / week+42.9% over 90 days020K40K60K80K100KSep 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-preval weekly downloads on npm, last 90 days: 82,629 weekly downloads as of Dec 5, 2026, +42.9% over 90 days.

7/30/90-day growth

babel-plugin-preval weekly downloads growth on npm: -0.5% over 7 days, +7.7% over 30 days, +42.9% over 90 days.babel-plugin-prevalWeekly downloads growth on npm82,629downloads / week now7-day growth-375 weekly downloads-0.5%30-day growth+5,923 weekly downloads+7.7%90-day growth+24,825 weekly downloads+42.9%Growth vs. nearest observation to each baseline date · Updated Dec 5, 2026pluginstats.com
babel-plugin-preval weekly downloads growth on npm: -0.5% over 7 days, +7.7% over 30 days, +42.9% over 90 days.

Ranking history

babel-plugin-preval npm ranking history: currently #668 (by weekly downloads).babel-plugin-prevalnpm ranking · by weekly downloads · Last 90 days#668current rank#650#660#670#680#690#700#710Sep 7Sep 22Oct 7Oct 22Nov 6Nov 21Dec 6rankOct 18, 2026 – Dec 6, 2026 · 44 observations · Updated Dec 5, 2026pluginstats.com
babel-plugin-preval npm ranking history: currently #668 (by weekly downloads).

Listing placement

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

Listing placement

Babel plugins263 listings · 14 pages · page 13, #6 (overall #246)
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-preval
Date (UTC)Weekly downloadsChange vs. previous
82,629-1.4K
83,979+1.3K
82,634+1.9K
80,726+482
80,244+2.3K
77,906-1.9K
79,843-3.2K
83,004+1.3K
81,661-118
81,779-2.7K
84,503+1.7K
82,792+2.3K
80,459+755
79,704—

Similar npm Babel plugins plugins

All 20 babel-plugin-preval 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-preval. First seen Oct 16, 2026; last successful collection Dec 6, 2026. See the methodology.