Skip to content

Commit 592ee90

Browse files
committed
switched to acorn for it's better es6 support
1 parent 9e12006 commit 592ee90

2 files changed

Lines changed: 19 additions & 21 deletions

File tree

‎lib/Parser.js‎

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
MIT License http://www.opensource.org/licenses/mit-license.php
33
Author Tobias Koppers @sokra
44
*/
5-
var esprima = require("esprima");
5+
var acorn = require("acorn");
66
var Tapable = require("tapable");
77
var BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
88

@@ -403,7 +403,7 @@ Parser.prototype.walkTryStatement = function walkTryStatement(statement) {
403403
this.walkStatement(statement.block);
404404
this.scope.inTry = false;
405405
}
406-
this.walkCatchClauses(statement.handlers);
406+
this.walkCatchClause(statement.handler);
407407
if(statement.finalizer)
408408
this.walkStatement(statement.finalizer);
409409
};
@@ -462,14 +462,12 @@ Parser.prototype.walkSwitchCases = function walkSwitchCases(switchCases) {
462462
}, this);
463463
};
464464

465-
Parser.prototype.walkCatchClauses = function walkCatchClauses(catchClauses) {
466-
catchClauses.forEach(function(catchClause) {
467-
if(catchClause.guard)
468-
this.walkExpression(catchClause.guard);
469-
this.inScope([catchClause.param], function() {
470-
this.walkStatement(catchClause.body);
471-
}.bind(this));
472-
}, this);
465+
Parser.prototype.walkCatchClause = function walkCatchClause(catchClause) {
466+
if(catchClause.guard)
467+
this.walkExpression(catchClause.guard);
468+
this.inScope([catchClause.param], function() {
469+
this.walkStatement(catchClause.body);
470+
}.bind(this));
473471
};
474472

475473
Parser.prototype.walkVariableDeclarators = function walkVariableDeclarators(declarators) {
@@ -777,7 +775,7 @@ Parser.prototype.parseCalculatedString = function parseCalculatedString(expressi
777775
});
778776

779777
Parser.prototype.parse = function parse(source, initialState) {
780-
var ast = esprima.parse(source, {range: true, loc: true, raw: true});
778+
var ast = acorn.parse(source, {ranges: true, locations: true});
781779
if(!ast || typeof ast !== "object")
782780
throw new Error("Source couldn't be parsed");
783781
var oldScope = this.scope;
@@ -796,7 +794,7 @@ Parser.prototype.parse = function parse(source, initialState) {
796794
};
797795

798796
Parser.prototype.evaluate = function evaluate(source) {
799-
var ast = esprima.parse("("+source+")", {range: true, loc: true, raw: true});
797+
var ast = acorn.parse("("+source+")", {ranges: true, locations: true});
800798
if(!ast || typeof ast !== "object" || ast.type !== "Program")
801799
throw new Error("evaluate: Source couldn't be parsed");
802800
if(ast.body.length !== 1 || ast.body[0].type !== "ExpressionStatement")

‎package.json‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
"author": "Tobias Koppers @sokra",
55
"description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jade, coffee, css, less, ... and your custom stuff.",
66
"dependencies": {
7-
"esprima": "~1.2.0",
8-
"mkdirp": "~0.5.0",
9-
"optimist": "~0.6.0",
10-
"uglify-js": "~2.4.13",
7+
"acorn": "^0.12.0",
118
"async": "~0.9.0",
9+
"clone": "~0.1.15",
1210
"enhanced-resolve": "~0.8.2",
1311
"memory-fs": "~0.2.0",
14-
"clone": "~0.1.15",
15-
"webpack-core": "~0.5.0",
12+
"mkdirp": "~0.5.0",
1613
"node-libs-browser": "~0.4.0",
17-
"watchpack": "^0.2.1",
14+
"optimist": "~0.6.0",
15+
"supports-color": "^1.2.0",
1816
"tapable": "~0.1.8",
19-
"supports-color": "^1.2.0"
17+
"uglify-js": "~2.4.13",
18+
"watchpack": "^0.2.1",
19+
"webpack-core": "~0.5.0"
2020
},
2121
"licenses": [
2222
{
@@ -48,7 +48,7 @@
4848
"component-webpack-plugin": "~0.2.0"
4949
},
5050
"engines": {
51-
"node": ">=0.6"
51+
"node": ">=0.6"
5252
},
5353
"repository": {
5454
"type": "git",

0 commit comments

Comments
 (0)