diff --git a/weak-map.js b/weak-map.js
index 9fa5d81..116ca05 100644
--- a/weak-map.js
+++ b/weak-map.js
@@ -77,7 +77,6 @@
  * prevent access to this channel. (See
  * PATCH_MUTABLE_FROZEN_WEAKMAP_PROTO in repairES5.js).
  */
-var WeakMap;
 
 /**
  * If this is a full <a href=
@@ -127,8 +126,8 @@ var WeakMap;
 
   // Check if there is already a good-enough WeakMap implementation, and if so
   // exit without replacing it.
-  var HostWeakMap = WeakMap;
-  if (typeof HostWeakMap === 'function') {
+  if (typeof WeakMap === 'function') {
+    var HostWeakMap = WeakMap;
     // There is a WeakMap -- is it good enough?
     if (typeof navigator !== 'undefined' &&
         /Firefox/.test(navigator.userAgent)) {
@@ -150,6 +149,7 @@ var WeakMap;
 
       // Fall through to installing our WeakMap.
     } else {
+      module.exports = WeakMap;
       return;
     }
   }
@@ -565,7 +565,7 @@ var WeakMap;
         });
       }
       DoubleWeakMap.prototype = OurWeakMap.prototype;
-      WeakMap = DoubleWeakMap;
+      module.exports = DoubleWeakMap;
 
       // define .constructor to hide OurWeakMap ctor
       Object.defineProperty(WeakMap.prototype, 'constructor', {
@@ -585,6 +585,6 @@ var WeakMap;
       Proxy = undefined;
     }
 
-    WeakMap = OurWeakMap;
+    module.exports = OurWeakMap;
   }
 })();
