Magic with Babel Macro

Rate this content
Bookmark

The talk will cover all the possibilities Babel Macro opens up and also gives an overview of Abstract Syntax Tree.

Dhrubesh Deb Sharma
Dhrubesh Deb Sharma
20 min
25 Oct, 2021

Comments

Sign in or register to post your comment.

Video Summary and Transcription

Babel macros allow for code transformation without multiple plugins, providing a solution to the downsides of regular Babel plugins. Understanding AST is crucial for developers working with transpilers, and exploring its structure and representations can help derive code. Babel started as a transpiler but has evolved into a tool for live code transformation. Babel macros are supported in various React-based frameworks and can be used for track translation and CSS to React Native macros. However, macros have limitations, such as being synchronous and evaluated at compile time.

Available in Español: Magia con Babel Macro

1. Introduction to Babel Macros

Short description:

In this talk, I will introduce Babel macros and explain how they can be used to write plugins and build macros.

A very good morning, a very good afternoon, and a good evening, based on where you're joining. My name is Trubesh and today I'm going to give a talk on magic with Babel macros. So before we dig in into the topic, I want to also talk about why this topic, right? So I think Babel macros was introduced back in 2017, 2018. And it seemed to be a really fascinating thing because of the things you can do just by that, right? A lot of patterns emerged because of that and, yeah, but nowadays not a lot of folks talk about it. So I thought, you know, why not give it a shot and see if you folks are interested. So the aim of this talk is to give you an introduction about Babel macros so that you can go ahead and write your own plugin perhaps or build your own macros.

2. Introduction to Srivesh and AST

Short description:

In this part, Srivesh introduces himself and his background in software development. He also mentions his YouTube channel and podcast. Srivesh then moves on to discuss the importance of AST in transpilers and the need for developers to understand it. He shares his experience of researching the term and provides a simplified definition of AST as a tree representation of source code that conveys its structure.

So my name is Srivesh. I'm from India. I work at a startup called Organize. I majorly handle the frontend side of things. We are also actively hiring. If anyone is looking out, please reach out to I also run a YouTube channel called the Junior Developer. And I host a podcast in that called the Junior Developer Podcast. If you are interested in frontend technologies or tech in general or maybe if you're interested in how to have an impactful development career, you should perhaps check out the channel and you might find some of the videos quite interesting. Also on Twitter, you can find me as dee underscore Junior underscore dev.

So, that's essentially my introduction. Let's get to the talk. So, AST, right? AST is an amazing thing. It stands for abstract syntax T. It's an amazing thing. And I feel that every developer should essentially learn about it. Because it's a it's essentially one of the building blocks of the transpilers which use your plugins to transpile your code, right? And without knowing it, you might not be able to understand how your code is being transpiled.

So, when I heard about this term AST, right, I got really curious and I, of course, boosted up my laptop and tried Googling what is an AST. And the first thing was of Wikipedia. And this was the definition which was thrown at me. It says in computer science, an abstract syntax tree or just syntax tree, is a representation of the abstract syntactic structure of text written in a formal language. So, this did not really this was a pretty complex definition for me. And it did not really hit me what exactly AST is. So, I tried to find a better definition which is much simpler in understanding. And I stumbled upon this definition. It says an abstract syntax tree or AST is a tree representation of the source code of a computer program that conveys the structure of source code. So, what it means by that is essentially you can look at the AST and you can derive what code you're writing. But as I mean it's of course not as readable as the human code which we write. But it's the representation is purely for machine to understand how exactly the code is structured.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Vite: Rethinking Frontend Tooling
JSNation Live 2021JSNation Live 2021
31 min
Vite: Rethinking Frontend Tooling
Top Content
Vite is a new build tool that intends to provide a leaner, faster, and more friction-less workflow for building modern web apps. This talk will dive into the project's background, rationale, technical details and design decisions: what problem does it solve, what makes it fast, and how does it fit into the JS tooling landscape.
React Compiler - Understanding Idiomatic React (React Forget)
React Advanced Conference 2023React Advanced Conference 2023
33 min
React Compiler - Understanding Idiomatic React (React Forget)
Top Content
React provides a contract to developers- uphold certain rules, and React can efficiently and correctly update the UI. In this talk we'll explore these rules in depth, understanding the reasoning behind them and how they unlock new directions such as automatic memoization. 
The Future of Performance Tooling
JSNation 2022JSNation 2022
21 min
The Future of Performance Tooling
Top Content
Our understanding of performance & user-experience has heavily evolved over the years. Web Developer Tooling needs to similarly evolve to make sure it is user-centric, actionable and contextual where modern experiences are concerned. In this talk, Addy will walk you through Chrome and others have been thinking about this problem and what updates they've been making to performance tools to lower the friction for building great experiences on the web.
How Bun Makes Building React Apps Simpler & Faster
React Day Berlin 2022React Day Berlin 2022
9 min
How Bun Makes Building React Apps Simpler & Faster
Bun’s builtin JSX transpiler, hot reloads on the server, JSX prop punning, macro api, automatic package installs, console.log JSX support, 4x faster serverside rendering and more make Bun the best runtime for building React apps

Workshops on related topic

Using CodeMirror to Build a JavaScript Editor with Linting and AutoComplete
React Day Berlin 2022React Day Berlin 2022
86 min
Using CodeMirror to Build a JavaScript Editor with Linting and AutoComplete
Top Content
WorkshopFree
Hussien Khayoon
Kahvi Patel
2 authors
Using a library might seem easy at first glance, but how do you choose the right library? How do you upgrade an existing one? And how do you wade through the documentation to find what you want?
In this workshop, we’ll discuss all these finer points while going through a general example of building a code editor using CodeMirror in React. All while sharing some of the nuances our team learned about using this library and some problems we encountered.
Solve 100% Of Your Errors: How to Root Cause Issues Faster With Session Replay
JSNation 2023JSNation 2023
44 min
Solve 100% Of Your Errors: How to Root Cause Issues Faster With Session Replay
WorkshopFree
Ryan Albrecht
Ryan Albrecht
You know that annoying bug? The one that doesn’t show up locally? And no matter how many times you try to recreate the environment you can’t reproduce it? You’ve gone through the breadcrumbs, read through the stack trace, and are now playing detective to piece together support tickets to make sure it’s real.
Join Sentry developer Ryan Albrecht in this talk to learn how developers can use Session Replay - a tool that provides video-like reproductions of user interactions - to identify, reproduce, and resolve errors and performance issues faster (without rolling your head on your keyboard).