AST size very large. Is this normal?

36 views
Skip to first unread message

Damien Golding

unread,
Jan 3, 2019, 5:18:50 AM1/3/19
to esprima
I tried using https://github.com/benjamn/recast which uses esprima by default according to the docs.
I executed against a small(120-ish lines) single js file which has only 2 small(60 lines) json files as external dependencies.
The outputted AST is over 30MB, growing to 120MB when formatted.

Is this normal? What kind of sizes is usual? Examples?
If not normal, what could be causing such a large size? It is difficult to search through millions of line of code and there are very few clues.

Additional information:
Code is private so can not share, but is just a class with static JS functions taking parameters(no references in the file so these shouldn't increase AST size much?) and uses module.exports, require format.

Any help would be much appreciated.
Regards.

Ariya Hidayat

unread,
Jun 30, 2019, 12:06:40 AM6/30/19
to esp...@googlegroups.com
Hi Damian,

That seems a bit weird indeed. The AST can be quite big but it should not be unreasonably large, compared to the source.

Is there a chance you can systematically slice the JavaScript source to narrow down the culprit?

Even better, would it be possible to redact the source in such a way that it can still demonstrate the issue?

Thank you very much!


--
Ariya Hidayat, https://ariya.io
Reply all
Reply to author
Forward
0 new messages