Skip to content

v0.3.0 - Much faster type binding resolution

Latest

Choose a tag to compare

@faultyserver faultyserver released this 18 Sep 03:06
· 5 commits to main since this release

A while ago, this switched from a simple global type scope to using an adaptation of babel-type-scopes, but the library was doing a lot of repetitive work, re-traversing the AST on every type lookup. In large files, this ends up being the majority of the time spent processing the file.

This version replaces that library adaptation with a new, pre-emptive, cached traversal of all type scopes in the file to create a re-usable map of bindings, meaning the file only needs to be traversed once, and afterwards every usage can just do a quick (recursive) lookup into the map.

In practice, this reduced the time to process import * as React from up to 5 seconds to consistently under 1 second on an M2 MacBook.