# facebookarchive/prepack

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/facebookarchive-prepack).**

14,118 stars · 412 forks · JavaScript · NOASSERTION · archived

## Links

- GitHub: https://github.com/facebookarchive/prepack
- Homepage: http://prepack.io
- awesome-repositories: https://awesome-repositories.com/repository/facebookarchive-prepack.md

## Topics

`javascript` `optimization`

## Description

Prepack is a build-time code evaluator and JavaScript bundle optimizer. It functions as a static analysis compiler that pre-evaluates static code and precalculates function results and global assignments during the build phase to accelerate startup times and reduce bundle size.

The project specifically targets JSX optimization by processing syntax and node serialization to improve user interface rendering efficiency. It utilizes a partial evaluation engine and static execution analysis to replace runtime computations with precalculated constants.

The tool covers a range of capabilities including the removal of TypeScript type annotations, the inlining of single-use expressions, and the simulation of environment-specific globals. It integrates into frontend build pipelines and can be operated via a command-line interface.

## Tags

### Programming Languages & Runtimes

- [Build-Time Evaluators](https://awesome-repositories.com/f/programming-languages-runtimes/build-time-evaluators.md) — Precalculates function results and global assignments during the build phase to accelerate startup times.
- [Partial Evaluation](https://awesome-repositories.com/f/programming-languages-runtimes/partial-evaluation.md) — Provides a partial evaluation engine that computes static expressions and function calls at build time.
- [Build-Time Execution Efficiency](https://awesome-repositories.com/f/programming-languages-runtimes/build-time-execution-efficiency.md) — Evaluates static functions and expressions during build to reduce startup times and memory allocations.
- [Constant-Folding Optimizations](https://awesome-repositories.com/f/programming-languages-runtimes/compile-time-constants/constant-folding-optimizations.md) — Performs constant-folding optimizations to replace complex operations with simple assignments at build time.
- [Constant Folding](https://awesome-repositories.com/f/programming-languages-runtimes/constant-folding.md) — Replace global bundle code with a sequence of assignments to eliminate runtime calculations and reduce object allocations. ([source](https://prepack.io/))
- [Partial Evaluation Compilers](https://awesome-repositories.com/f/programming-languages-runtimes/partial-evaluation-compilers.md) — Analyzes source code to inline expressions and remove unused abstractions through build-time partial evaluation.
- [Side-Effect Analysis](https://awesome-repositories.com/f/programming-languages-runtimes/side-effect-analysis.md) — Performs side-effect analysis to determine which functions can be safely precalculated.
- [Expression Inlining](https://awesome-repositories.com/f/programming-languages-runtimes/expression-inlining.md) — Replace expressions used only once with their actual values to reduce variable naming overhead and memory usage. ([source](https://prepack.io/repl.html))
- [Global Environment Modeling](https://awesome-repositories.com/f/programming-languages-runtimes/global-environment-modeling.md) — Simulates browser or server globals during compilation to evaluate environment-dependent code.
- [Runtime Environment Simulations](https://awesome-repositories.com/f/programming-languages-runtimes/runtime-environment-simulations.md) — Defines the behavior of environment-specific globals to evaluate code referencing browser or server objects. ([source](https://prepack.io/))
- [Type Annotation Stripping](https://awesome-repositories.com/f/programming-languages-runtimes/type-annotations/type-annotation-stripping.md) — Removes TypeScript type annotations from source code to produce executable JavaScript files. ([source](https://prepack.io/repl.html))

### Software Engineering & Architecture

- [JavaScript Optimization](https://awesome-repositories.com/f/software-engineering-architecture/performance-reliability/performance-optimization/application-performance-tuning/javascript-optimization.md) — Optimizes JavaScript execution by precalculating static code paths during the build process. ([source](https://cdn.jsdelivr.net/gh/facebookarchive/prepack@main/README.md))
- [Syntax Tree Transformers](https://awesome-repositories.com/f/software-engineering-architecture/trees/syntax-tree-construction/syntax-tree-transformers.md) — Implements syntax tree transformations to inline expressions and strip type annotations during the build process.

### User Interface & Experience

- [Rendering Optimization](https://awesome-repositories.com/f/user-interface-experience/rendering-optimization.md) — Optimizes the rendering of React components by streamlining JSX node serialization. ([source](https://prepack.io/repl.html))

### Web Development

- [Bundle Optimizers](https://awesome-repositories.com/f/web-development/bundle-optimizers.md) — Provides a bundle optimizer that reduces JavaScript bundle size and execution time.
- [Serialization Optimizers](https://awesome-repositories.com/f/web-development/jsx-syntaxes/serialization-optimizers.md) — Processing JSX syntax and node serialization at build time to improve the speed of user interface rendering.
- [JSX Transformers](https://awesome-repositories.com/f/web-development/jsx-transformers.md) — Transforms JSX syntax into optimized JavaScript calls to improve rendering efficiency.

### Development Tools & Productivity

- [Build-Time Code Generators](https://awesome-repositories.com/f/development-tools-productivity/build-time-code-generators.md) — Generates optimized code bundles by evaluating static parts of the program during the build phase. ([source](https://prepack.io/repl.html))
- [Frontend Build Tools](https://awesome-repositories.com/f/development-tools-productivity/build-tooling/build-orchestration-logic/build-orchestration-configuration/build-automation-systems/frontend-build-tools.md) — Acts as a frontend build tool by integrating a bundle optimizer into the compilation pipeline.
- [Build Tool Integrations](https://awesome-repositories.com/f/development-tools-productivity/workflow-automation-tools/build-task-automation/build-tool-integrations.md) — Integrates with module bundlers and compilers to automate the evaluation process within build pipelines. ([source](https://prepack.io/frequently-asked-questions.html))
