Avoid using exports when undefined (#1471)
authorOndřej Španěl <OndrejSpanel@users.noreply.github.com>
Fri, 24 Feb 2017 00:51:24 +0000 (01:51 +0100)
committerAlex Lam S.L <alexlamsl@gmail.com>
Fri, 24 Feb 2017 00:51:24 +0000 (08:51 +0800)
Makes direct usage within web browser easier, even if officially unsupported.

lib/ast.js

index 42506cb..61643ae 100644 (file)
@@ -81,7 +81,9 @@ function DEFNODE(type, props, methods, base) {
     ctor.DEFMETHOD = function(name, method) {
         this.prototype[name] = method;
     };
-    exports["AST_" + type] = ctor;
+    if (typeof exports !== "undefined") {
+        exports["AST_" + type] = ctor;
+    }
     return ctor;
 };