From f6f7310a50c771fa58145c9f8f03ddbc0432e745 Mon Sep 17 00:00:00 2001 From: Jesse Gibson Date: Mon, 23 Nov 2015 15:32:48 -0700 Subject: [PATCH] Add basic compatibility with browserify and webpack On the compile step, both window and module are defined. Gun prevents module exports by detecting the environment and tacking Gun onto the window object. This addition will check to see if it's a dual environment (like browserify or electron) and export to both window and module, preventing errors in your build step. --- gun.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gun.js b/gun.js index 7351d3aa..6c05f006 100644 --- a/gun.js +++ b/gun.js @@ -980,6 +980,9 @@ }({})); if(typeof window !== "undefined"){ window.Gun = Gun; + if(typeof module !== 'undefined' && module.exports){ + module.exports = Gun; + } } else { module.exports = Gun; }