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

TypeError: Cannot set property 'parent' of null #19

Closed nathanbowser closed 9 years ago

nathanbowser commented 11 years ago

If you try to walk the source of wysihtml5, detective will throw TypeError: Cannot set property 'parent' of null -- /node-detective/index.js:7:22

Here is a simple example that demonstrates the problem:

var detective = require('detective')
  , request = require('request')

request('https://raw.github.com/xing/wysihtml5/master/dist/wysihtml5-0.4.0pre.js', function (err, response, src) {
  console.dir(detective(src))
})

Here is the node it's looping over. I can't figure out what is causing the node to be null, but it looks like that comes from esprima or escodegen

[ null,
  { type: 'Literal', value: 0 },
  parent: { type: 'ArrayExpression',
    elements: [Circular],
    parent: 
     { type: 'LogicalExpression',
       operator: '||',
       left: [Object],
       right: [Circular],
       parent: [Object] } } ]

I found this issue when upgrading to browserify v2.

nathanbowser commented 11 years ago

The null returned from esprima is caused by this [,0]. I'll throw together a test.

zertosh commented 9 years ago

Fixed by https://github.com/substack/node-detective/pull/21