Web apps are evolving targets which show their age via varying degrees of code cruft. And that’s ok. Tech debt is an expected side-effect of living production web apps, and the challenge lies in paying down the debt while still pushing forward.
Enter Abstract Syntax Trees…
ASTs enable developers to parse input code into a predictable tree data structure that can be easily traversed, manipulated and then regenerated in place. Transpilers such as BabelJS use this powerful pattern to transpile ES2015+ down to a baseline of ES5.
While this 1:1 transpiling is the most common usage of ASTs, they can also be leveraged to supercharge the transformation of your legacy code to meet the conventions, libraries, and/or design patterns your team is using today.
Amal aims to demystify this process by breaking down the steps of how to build your own custom AST based transforms.