Top level only parse

Is acorn able to just parse the top level of a file?
To generate ast for the top level and chunk everything else into some bulk blob.
I’m looking to do a transform on the top level (import/export) and don’t care about the rest.
I see a Parse#parseTopLevel but it’s recursive (drilling all the way in).

1 Like

Nope. But unless you’re doing something really performance-sensitive, it probably doesn’t matter.

@jdalton, Facing same challenge, what solutions you come up with?

@marijn, is there a way to make top level parsing more performant than deeper ones?
Say by using options or some kind of plugin allowing to disable in-depth activities and storing the AST data.

You could write a plugin that does this. This isn’t likely to be added to the core library.