Babel Plugin Preval
JSON →babel-plugin-preval is a Babel plugin designed to pre-evaluate JavaScript code at build-time, effectively replacing dynamic runtime computations with static, precomputed values. Its current stable version is 5.1.0. While the last major release was in 2022, the package continues to be used, with discussions and related macro packages still active in the community. This plugin allows for tasks like reading file systems or performing complex calculations during the build process, which are typically impossible or inefficient at runtime, especially in browser environments. Unlike generic build-time evaluators, preval integrates directly into the Babel compilation pipeline and provides multiple mechanisms for invocation, including template literal tags, `preval.require` calls, and `/* preval */` import comments. A crucial distinction is that the code executed by `preval` runs directly in a Node.js environment, is not sandboxed, and is *not* automatically transpiled by Babel, meaning it must be compatible with the Node.js version used for the build process.
Traffic · last 30 days ↓56% vs prev 7d
top countries 🇺🇸 United States · 🇩🇪 Germany · 🇸🇬 Singapore · 🇨🇦 Canada · 🇫🇷 France