browserify / detective

Find all calls to require() no matter how deeply nested using a proper walk of the AST
Other
414 stars 61 forks source link

Use acorn's own traverser #55

Closed zertosh closed 9 years ago

zertosh commented 9 years ago

Fixes https://github.com/substack/node-detective/pull/53.

Although we're now only visiting CallExpression nodes for the custom isRequire case, as opposed to all nodes, I'm not considering this a breaking change. There's been an implicit assumption that only CallExpression (and I guess NewExpression) nodes where being visited before this change. It's assumed that any node that isRequire returns true for has an arguments object. Returning true for any other type of node, would've thrown since no other types have an arguments property.

Benchmark results:

# before
$ for i in {1..5}; do node bench/detect.js; done
140
132
143
125
133

# after
$ for i in {1..5}; do node bench/detect.js; done
100
105
105
105
106