browserify / detective

Find all calls to require() no matter how deeply nested using a proper walk of the AST

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: Cannot set property 'parent' of null

nathanbowser opened this issue · comments

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.

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

Fixed by #21