diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c4b66d1c..35feddad8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ Change Log v5.4.1 --- +* Fixed `Utils.nodeRequire` causing `ReferenceError: require is not defined` in browser build by making it lazy-evaluated * Fixed missing space between keywords (`return`, `throw`, `typeof`) and Unicode surrogate pair identifiers in compact mode. Fixes https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1112 * Fixed `domainLock` being case-sensitive — domain values are now normalized to lowercase. Fixes https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1182 * Removed `source-map-support` runtime dependency. Use `node --enable-source-maps` instead. Fixes https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1149 diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index 9800c807a..f6f47d6f7 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -12,9 +12,12 @@ export class Utils { /** * Dynamic require that bypasses webpack bundling. * Use for Node.js-only modules that should not be included in the browser build. + * Lazy-evaluated to avoid ReferenceError in browser environments. */ // eslint-disable-next-line no-eval - public static readonly nodeRequire: NodeRequire = eval('require'); + public static get nodeRequire(): NodeRequire { + return eval('require'); + } /** * @param {string} version