From baa50faa66524e220a59f8fe86c1219537b5af82 Mon Sep 17 00:00:00 2001 From: Brad Gearon Date: Thu, 13 Jun 2024 11:18:41 -0500 Subject: [PATCH] still setting module.exports when reusing already defined global object this resolves issues when using the npm module after having Sugar already loaded globally --- lib/core.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/core.js b/lib/core.js index 9b28df75d..cbc19bae2 100644 --- a/lib/core.js +++ b/lib/core.js @@ -64,6 +64,11 @@ function setupGlobal() { Sugar = globalContext[SUGAR_GLOBAL]; // istanbul ignore if if (Sugar) { + if (typeof module !== 'undefined' && module.exports) { + // Node or webpack environment + module.exports = Sugar; + } + // Reuse already defined Sugar global object. return; }