{"library":"babel-plugin-preval","type":"library","category":null,"description":"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.","language":"javascript","status":"maintenance","version":"5.1.0","tags":["javascript","babel","babel-plugin","eval","precompile","babel-plugin-macros","typescript"],"last_verified":"Wed May 27","install":[{"cmd":"npm install babel-plugin-preval","imports":["// In babel.config.js or .babelrc\nmodule.exports = {\n  plugins: ['babel-plugin-preval'],\n};","const staticValue = preval`module.exports = 1 + 1`;","const buildTimeData = preval.require('./config-generator.js');","import precomputedValue from /* preval */ './constants.js';"]},{"cmd":"yarn add babel-plugin-preval","imports":[]},{"cmd":"pnpm add babel-plugin-preval","imports":[]}],"homepage":null,"github":"https://github.com/kentcdodds/babel-plugin-preval","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/babel-plugin-preval","openapi_spec":null,"status_page":null,"smithery":null,"compatibility":{"summary":{"python_range":"18–22","success_rate":0,"avg_install_s":null,"avg_import_s":null,"wheel_type":null},"url":"https://checklist.day/v1/registry/babel-plugin-preval/compatibility"}}