Magic With Babel Macro - Dhrubesh Deb Sharma, React Advanced 2021

Learn how to unlock the power of Babel Macros for transformative coding with Dhrubesh Deb Sharma at React Advanced 2021, exploring code manipulation, AST, and more.

Key takeaways
  • Babel Macros are a way to apply transformations to code without having to write plugins for each transformation.
  • Macros are evaluated at compile-time and can be used to manipulate the Abstract Syntax Tree (AST).
  • AST is a tree representation of the source code of a programming language.
  • AST is used by transpilers like Babel to transform code.
  • Babel Macros can be used to write code that can be used across CRA, Gatsby, Next.js, and other React-based frameworks.
  • Macros are synchronous, unlike regular Babel plugins.
  • AST can be used to derive the code structure and understand the transformation process.
  • The order in which plugins are loaded and configured is important.
  • Regular Babel plugins can have downsides, such as difficulty in setting up and configuring.
  • Babel Macros are a more concise and readable alternative to regular Babel plugins.
  • AST Explorer can be used to explore and manipulate AST.
  • The getSpeakerName function can be used to derive the speaker name from the AST.