Lodash Internal reEvaluate Module
This package, `lodash._reevaluate`, provides a standalone module for the internal `reEvaluate` function from the Lodash library, specifically mirroring its implementation as found in Lodash version 3.0.0. It was created to offer a modularized CommonJS build for Node.js and io.js environments. The core Lodash library, which this internal function supports, has since evolved to version 4.x, with its most recent release being 4.18.1. Consequently, `lodash._reevaluate` at version 3.0.0 is effectively unmaintained and has not received updates or new features corresponding to the active development of Lodash v4. This means it lacks compatibility with modern Lodash features, bug fixes, and security patches. As an internal helper, its primary role is in supporting Lodash's template compilation engine. Users should be aware that this module represents an outdated snapshot and is not recommended for new projects or integration with current Lodash versions, as its functionality is now handled internally and more robustly within the main `lodash` package.
Common errors
-
TypeError: reEvaluate is not a function
cause Attempting to use `lodash._reevaluate` in an environment or with a bundler that expects ESM imports, or trying to use a method that isn't the primary export.fixEnsure you are using CommonJS `require` syntax: `const reEvaluate = require('lodash._reevaluate');`. This module does not provide named or default ESM exports. -
ReferenceError: require is not defined
cause Trying to use this CommonJS-only package directly in an ESM-only Node.js environment, or in a browser without a compatible bundler.fixFor ESM environments, you would need to either transpile your code or use a dynamic import workaround (`import('lodash._reevaluate')`). In browsers, a bundler like Webpack or Rollup configured for CommonJS modules is required. However, it's advised to avoid this deprecated package entirely.
Warnings
- breaking This `lodash._reevaluate` package is locked at version 3.0.0 and is not compatible with or supported for use with Lodash v4.x and newer versions. The main Lodash library introduced significant breaking changes in v4.0.0, and this internal module's implementation is specific to Lodash v3.
- deprecated This standalone `lodash._reevaluate` package is effectively abandoned and deprecated. It has not received updates since the release of Lodash v3.0.0, meaning it lacks bug fixes, performance improvements, and security patches present in modern Lodash versions.
- gotcha As an outdated and unmaintained package, `lodash._reevaluate` may contain unpatched security vulnerabilities. For instance, the main Lodash package (v4.x) has received critical security updates (e.g., GHSA-f23m-r3pf-42rh for prototype pollution in `_.unset` / `_.omit`), but this module would not benefit from such fixes if it were to expose similar issues.
Install
-
npm install lodash._reevaluate -
yarn add lodash._reevaluate -
pnpm add lodash._reevaluate
Imports
- reEvaluate
import reEvaluate from 'lodash._reevaluate';
const reEvaluate = require('lodash._reevaluate'); - reEvaluate (named)
import { reEvaluate } from 'lodash._reevaluate';const reEvaluate = require('lodash._reevaluate'); - Type of reEvaluate
import type { ReEvaluateFunction } from 'lodash._reevaluate';/* No official types provided */
Quickstart
const reEvaluate = require('lodash._reevaluate');
// reEvaluate is an internal Lodash function primarily used for template compilation.
// It expects a string template and an object representing the data context.
// This example is illustrative; direct use of this internal function is rare outside of Lodash's own core.
const compiledTemplate = reEvaluate('<%- envVar %>: <%= value %>', {
escape: (val) => String(val).replace(/[&<>'"`/]/g, ''),
interpolate: (val) => String(val),
evaluate: (val) => { try { return eval(val); } catch (e) { return ''; } } // UNSAFE for untrusted input
});
console.log(compiledTemplate({ envVar: 'NODE_ENV', value: process.env.NODE_ENV ?? 'development' }));
// Note: This package is for Lodash v3 internals. Modern Lodash (v4+) handles templating differently and securely.
// Direct usage of 'reEvaluate' is generally discouraged and unsupported.