From f93d546ee0626dfe1df34bae8040db2f790914c0 Mon Sep 17 00:00:00 2001 From: Arne Goedeke Date: Thu, 2 Mar 2023 09:48:16 +0100 Subject: [PATCH] `randombytes`: Replace run-time require detection Using require() as an expression leads to compile errors in webpack. This issue can be solved by guarding the use of require by the 'correct' run-time check using `typeof require`. --- randombytes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/randombytes.js b/randombytes.js index 5d6f442..c497ec3 100644 --- a/randombytes.js +++ b/randombytes.js @@ -20,7 +20,7 @@ var randombytes = (function () { if (crypto && crypto.getRandomValues) return browserBytes - if (require != null) { + if (typeof require === 'function') { // Node.js. Bust Browserify crypto = require('cry' + 'pto') if (crypto && crypto.randomBytes) return nodeBytes