prepack
A JavaScript bundle optimizer.
An archived Facebook tool that pre-evaluates JavaScript before it runs, pre-computing constants and startup work so the optimized version loads faster. No longer actively maintained.
Prepack is a tool for making JavaScript code run faster. JavaScript is the programming language that powers most interactive websites and apps. When a program starts up, it often does a lot of repetitive setup work. Prepack reads a JavaScript file ahead of time, figures out parts of that work in advance, and rewrites the file into a version that produces the same result while doing less work when it actually runs. The makers describe it as a partial evaluator: it pre-computes whatever it safely can before the code ever reaches the user.
An important note in the README is that the project is paused. The team at Facebook that built it has set the work down, including a related React compiler effort, so there is little ongoing activity. The repository now lives under Facebook's archive account, which signals that it is no longer actively maintained.
For people who still want to try it, the README explains how to install it as a command-line tool through the npm or yarn package managers. Once installed, you point it at a JavaScript file and it prints the optimized result to the screen or saves it to a new file. There are also separate plugins, maintained by other people, that connect Prepack to popular build tools such as Rollup, Webpack, and Parcel, as well as an editor extension for Visual Studio Code.
The rest of the document is aimed at developers who want to work on Prepack itself. It walks through cloning the code, setting up the required tools, and the commands for building, checking, and testing it. It also explains how to run an interactive session, how to edit the project's website, which is stored in the same repository, and where to find contribution guidelines.
Prepack is released under the BSD license with an additional patent grant.
Where it fits
- Speed up a JavaScript app's startup time by pre-computing initialization work at build time.
- Integrate Prepack into a Webpack or Rollup build pipeline to automatically optimize bundle output.
- Study how a JavaScript partial evaluator works by reading through the archived research-grade source code.
- Experiment with pre-evaluation concepts for academic or research purposes.