compiler: ensure we only visit nodes once
@doc-han is already working on this.
Since Oct 3, 2025.
- Dominant language
- TypeScript
- Stars
- 21
- Forks
- 23
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 17
Description
The way the compiler works right now is that a number of "transformers" will each visit the AST and run their own analysis.
And add-imports for example invokes a child visitor. I mean I've implemented that as a visitor on Program, but it's it really a visitor on Identifier? I guess the problem is that state needs to be passed to another process - althouhh perhaps it could just scribble somewhere
What we really need is to consolidate all the transformers into a single visit. This means that when traversing a huge file, we significantly reduce the CPU and memory overhead of compilation.
Some difficulties:
- what if one transformer wants to abort and ignore a whole subtree? Is this something we really need? If there's only one visit per node it doesn't feel so useful. Perhaps we can annotate paths and pass information downstream
- How do we control ordering? some transformers need to run before others right now (right??). That's harder to figure out in a single traversal
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.