Skip to content

Commit

Permalink
Avoid using exports when undefined (#1471)
Browse files Browse the repository at this point in the history
Makes direct usage within web browser easier, even if officially unsupported.
  • Loading branch information
OndrejSpanel authored and alexlamsl committed Feb 24, 2017
1 parent 229e42c commit 852f784
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/ast.js
Expand Up @@ -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;
};

Expand Down

3 comments on commit 852f784

@asplogic
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI... I just got an error running my webpack after updating my npm... not sure which of the last 3 commits it was...

SyntaxError: Unexpected token: punc (,)
Error.../node_modules/uglify-js/tools/node.js:28:1),

this is what i am including...
"uglify-js": "git://github.com/mishoo/UglifyJS2.git#harmony",

@kzc
Copy link
Contributor

@kzc kzc commented on 852f784 Feb 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch wasn't committed to the harmony branch.

@asplogic
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opps sorry...

Please sign in to comment.