From 30e1ac751327dcc5b85c25c2fade1e9932b04ca6 Mon Sep 17 00:00:00 2001 From: Avi Vahl Date: Wed, 26 Jan 2022 14:37:48 +0200 Subject: [PATCH] fix: ensure no warnings when bundled (#50) * fix: ensure no warnings when bundled node "util" is now mapped to an empty object and checked in runtime. addresses https://github.com/chaijs/chai/issues/1447 * style: lint fixes Co-authored-by: Keith Cirkel --- index.js | 3 ++- package.json | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 670e55c..0a27ca8 100644 --- a/index.js +++ b/index.js @@ -29,7 +29,8 @@ const chaiInspect = symbolsSupported ? Symbol.for('chai/inspect') : '@@chai/insp let nodeInspect = false try { // eslint-disable-next-line global-require - nodeInspect = require('util').inspect.custom + const nodeUtil = require('util') + nodeInspect = nodeUtil.inspect ? nodeUtil.inspect.custom : false } catch (noNodeInspect) { nodeInspect = false } diff --git a/package.json b/package.json index 53a5db0..a090b3f 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,9 @@ ], "main": "./loupe.js", "module": "./index.js", + "browser": { + "util": false + }, "repository": { "type": "git", "url": "https://github.com/chaijs/loupe"