Make Utils.nodeRequire lazy-evaluated to avoid ReferenceError in browser environments

This commit is contained in:
sanex3339
2026-03-22 19:45:03 +07:00
parent 459fb31c12
commit 199d8433cf
2 changed files with 5 additions and 1 deletions
+1
View File
@@ -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
+4 -1
View File
@@ -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