Abstract Syntax Trees
course
The underpinnings of tools like Babel and ESLint, Abstract Syntax Trees (or ASTs) are not nearly as scary as you might think. This is a collection of all the egghead.io lessons I (Kent) have put out there.
Browse
Find courses, lessons, articles, talks, and podcasts.
49 results for "babel"
Showing 25–48 · Page 2 of 3
course
The underpinnings of tools like Babel and ESLint, Abstract Syntax Trees (or ASTs) are not nearly as scary as you might think. This is a collection of all the egghead.io lessons I (Kent) have put out there.
lessonDuration 2m 10s
There are a bunch of different ways that you can compile TypeScript and how you go about doing it will depend largely on what build tooling that you use. Since I'm using `rollup` and `babel` already to transpile my TypeScript code, I think it makes sense to utilize babel's typescript preset to handle all of our TypeScript compilation as well. So we will install it with `npm i -D @babel/preset-typescript` and configure it in our `rollup.config.js`.
lessonDuration 2m 36s
La nueva versión de Javascript trae, entre sus nuevas características la posibilidad de utilizar importación dinámica de forma nativa en el navegador utilizando la misma sintaxis que ya hemos utilizado con webpack/rollup y Babel. Se trata de la implementación de la sintaxis `import()` que retorna una Promesa permitiendo así importar módulos de forma programática incluso dentro de bloques condicionales, eventos o utilizando la sintaxis `async` y `await`.
lessonDuration 2m 56s
[create-react-app version 2.0](https://reactjs.org/blog/2018/10/01/create-react-app-v2.html) added a lot of new features. One of the new features is upgrading to [Babel Version 7](https://babeljs.io/blog/2018/08/27/7.0.0#jsx-fragment-support), which enables the Short Syntax of [React Fragments](https://reactjs.org/docs/fragments.html#short-syntax). Fragments have been a feature of React since version 16.2, but the Short Syntax hasn’t been available since Babel 7.0. Fragments let you wrap a group of children without adding an extra node to the DOM, which is helpful if you need a specific DOM structure.
lessonDuration 5m 47sFree
JSX is not an entirely different language, but it is a bit of an extension to the language, so knowing how you would express certain JavaScript things within the JSX syntax is important to using JSX effectively. In this lesson we’ll explore a few different things you can do with JSX, like interpolation, composition, and spreading props. And we’ll compare these syntaxes with what is generated by babel so we have a good understanding of how this translates to regular JavaScript calls into `React.createElement`.
lessonDuration 2m 26sFree
Getting started with a new frontend project can be daunting. Sometimes, configuring Babel, [webpack](/q/webpack), eslint, Jest and all the other tools common to most frontend applications, just holds you back from building something. The [React](/q/react) team has built and maintains create-react-app so you can start a project quickly without having to worry about setting up all the tooling. You get everything pre-configured with a lot of really sensible defaults. In this lesson, we'll bootstrap a project with npx and create-react-app so we can get right into building apps with React.
lessonDuration 1m 57sFree
One of the common pitfalls when learning React is related to event handlers losing the reference to `this` pointing to the component when called. Common approach to solving this issue is to use a `constructor` and `.bind()` function to bind all class methods to `this` object, referring to the component itself. It sometimes leads to a `constructor` which sole purpose is to bind a bunch of methods. In this lesson we are going to learn how to use a public class field syntax (currently available in Babel stage-2 and enabled by default in create-react-app) to avoid having to create unnecessary constructors in order to bind a React component method to proper `this`
lessonDuration 2m 37sFree
HTML is the standard way to define UI for browsers and it's a great way of representing the hierarchical structure of a web page. Since React is a JavaScript framework, all of the UI we build needs to be defined in JavaScript code, but that doesn't lend itself to being able to quickly write or read the code that defines our UI in terms of the HTML that will be rendered in the browser. Instead of writing raw, JavaScript functions, we'll write in JSX (JavaScript XML) to define our UI structure in a familiar, HTML-like, syntax and let the tools (Babel, specifically) turn that into standard JavaScript for the browser. In this lesson, we'll use JSX to render a static version of the beginning of our application.
lessonDuration 1m 19sFree
Gatsby Recipes are a new tool of the gatsby-cli which require the latest install of the package. You will need to install the cli with `npm install -g gatsby-cli@latest` Gatsby Recipes allow you to add common functionality to your Gatsby site with none of the headache of dealing with all the various plugins that would are required. In this lesson, you will see how easy it is to install and run `Jest` with an official Gatsby recipe. What used to be a multiple step process (including modifying babel configs) is now a simple install command away.
lessonDuration 2m 48sFree
In this lesson, we start a new React project using `create-react-app`. This allows us to not have to worry about tooling like webpack, babel etc. Once installed, we'll remove some of the files we don't need, add some CSS for our project, so we're ready to get started.
lessonDuration 3m 27sFree
# Up and Running with Parcel JS In this video, we will get up and running with Parcel by creating a simple Hello World application in JavaScript. ## What is Parcel? Parcel is a zero configuration web application bundler and Webpack alternative. It supports a ton of functionality out of the box, including Code Splitting, Hot Module Replacement, Environment Variables, and Automatic Transforms for Babel, PostCSS, and PostHTML. ## Asset Support It supports nearly any type of asset you would typically use in a JavaScript project, including: * HTML * Images * Fonts * JavaScript * TypeScript * CoffeeScript * Vue * ReasonML * CSS * SCSS * LESS * Stylus * JSON * GraphQL * Rust * WebAssembly * YAML * TOML * OpenGL * Pug * WebManifest Learn more at [Parcel's website](https://parceljs.org/getting_started.html).
lessonDuration 1m 39s
In this course, we'll learn how to use the new features available in the latest version of javascript, commonly referred to as ES2019. ES2019 is available in the latest version of Chrome, Firefox, Safari, and Node, and are available via compilation with Babel or Typescript. The goal of this course is to introduce you to opportunities to use ES2019 in real situations from within an existing student grade tracking Nuxt.js application, and explore real world use cases and opportunities to use ES2019's new features. We'll learn together as we discover how to use Object.fromEntries, Symbol.prototype.description, Array.prototype.flatMap, Array.prototype.flat, String.prototype.trimStart, String.prototype.trimEnd, Optional Catch binding, and Array Stable Sorting. By the end of this course, you’ll know how and when to use ES2019 to accomplish more with less code, and my hope is that you'll be inspired to stay up to date with the latest changes to the core JS language as they come out.
lessonDuration 1m 12s
In order to get up and going with Enzyme and Jest, some configurations are required. We will need to install some babel plugins, create a specific package json script, and depending on which version of Jest, add Jest configurations to our package.json.
lessonDuration 50s
In this course, we'll start with an empty directory and build up a starter project for building a React application. Along the way, we'll work with webpack and babel to transform, code-split, and bundle our code. We'll create npm scripts to execute commands and work with git and GitHub to track changes and share our code in public. We'll build quality into our project with Jest for unit testing and ESLint for static analysis. We'll configure Prettier for formatting and then enforce all these quality checks before commit with git hooks. We'll even incorporate some accessibility checks and enforce some best practices in React with react-axe, React's StrictMode and a default ErrorBoundary component. Whether you end up using the resulting project to start new projects of your own, or you continue to use great community tools like Create React App, you'll leave this course understanding the underlying tools and how they work together.
lessonDuration 14m 24sFree
In this lesson we'll use yarn and yarn workspaces to create a monorepo that includes a web creat-react-app, a react-native app, and shared code. We'll use `react-app-rewired` and `react-app-rewire-babel-loader` to rewire the create-react-app configuration to allow babel to process the shared code from workspace. We'll also use `crna-make-symlinks-for-yarn-workspaces` and `metro-bundler-config-yarn-workspaces` to configure the react-native app to be able to find the shared code in the workspaces.
lessonDuration 1m 35sFree
Hyperapp is an ultra lightweight (1kb), minimal, functional, JavaScript library for building UIs. It comes with a VDOM engine and state management without any dependencies. In this lesson, we learn how to use JSX with Hyperapp. By installing a Babel plugin, we can instruct it to transpile JSX to Hyperapp's `h` method for a better developer experience.
lessonDuration 1m 14s
Poi uses the Vue babel presets by default, so there is no additional install required to get up-and-running. You can even use the `.vue` file format without having to configure anything.
lessonDuration 1m 34sFree
In this lesson we’ll look at the amazing open source tool [ASTExplorer.net](https://astexplorer.net/). We’ll learn how we can use it to learn about ASTs generated by different tools. We’ll also see how it can be used to help us write plugins for ESLint, Babel, and other tools. The noted ESTree specification can be found on [GitHub](https://github.com/estree/estree).
lessonDuration 1m 54sFree
In this lesson, we’ll learn about the key technology used by JavaScript engines and tools like ESLint and Babel to run, lint, and modify your source code. The JavaScript Abstract Syntax Tree (or AST for short) is a JSON representation of your code that is represented by a tree structure. In this lesson we’ll explore that tree structure to get a feel for how code translates to an AST.
lessonDuration 1m 5sFree
Setting up tooling for a basic React app is typically very hard to do and requires a lot of configuration. In this lesson, we will setup a new React project with Neutrino with zero configuration. Neutrino uses Webpack and Babel behind the scenes, so you still get great build technology, but without all the heavy lifting of needing to configure it.
lessonDuration 4m 57s
By creating a simple ‘hello world’ example application first in vanilla Javascript, and then in Preact without any tools, we’ll learn what type of problems Preact is solving for us and how is works at a low level. Then we’ll switch to a Webpack + Babel setup we’ll cover some fundamental concepts such as, which imports we need, how to create a component, how to use JSX and finally how to render our component into a target element in a web page.
lessonDuration 3m 24s
Although technically you can run Preact without any tools or pre-compiling, we’ll get a much better development experience by using modern versions of Javascript along with JSX. To achieve this, we'll be installing `babel-core` along with [`babel-preset-env`](https://egghead.io/lessons/node-js-use-babel-preset-env-with-native-node-features-and-also-use-babel-plugins). This combination will provide us with a set of plugins suitable for transpiling our code for use in modern browsers. It doesn't include support for JSX however, so we'll add the `babel-plugin-transform-react-jsx` plugin to handle that part. Along with creating a Javascript file that can be executed in the browser, we also want to preview our work each time we change a file - so we install [Webpack](https://egghead.io/playlists/learning-webpack) and the Webpack Dev Server to handle both of those tasks. The final dependency we install is `babel-loader` which will allow the source files being accessed by Webpack to first be processed by Babel and the plugins we specified.
lessonDuration 5m 18sFree
If you're used to using all the latest ES6+ hotness on the front end via Babel, working in Node.js can feel like a step back. Thankfully, it's easy to bring all the Babel goodness with you to the backend, and that's exactly what this lesson covers.
lessonDuration 3m 16sFree
The app is built on top of [vite](https://vitejs.dev/) instead of the more popular [create react app](https://reactjs.org/docs/create-a-new-react-app.html). The benefit of vite is that it installs and builds extremely quickly. One of the downsides of vite is that it doesn't come with any out-of-the-box testing support. It also has its own [esbuild-based compiler](https://vitejs.dev/guide/features.html#typescript), which is not currently compatible with jest, so we have to configure JSX & TypeScript support for jest even though `vite` handles that already for our app. This lesson requires installing a handful of modules: ``` npm install -D jest npm install -D @testing-library/react @testing-library/jest-dom @testing-library/user-event npm install -D @babel/preset-react @babel/preset-typescript @babel/preset-env npm install -D identity-obj-proxy ``` Each of them serves an important purpose: - [jest](https://jestjs.io/) _runs our tests_ - [@testing-library/react](https://testing-library.com/docs/react-testing-library/intro) adds the ability to render react components inside of our test environment - [@testing-library/jest-dom](https://github.com/testing-library/jest-dom) _allows us to assert that components are in the DOM and contains certain text and classes_ - [@testing-library/user-event](https://testing-library.com/docs/ecosystem-user-event) _allows us to interact with rendered components programmatically_ - [@babel/preset-react](https://babeljs.io/docs/en/babel-preset-react), [@babel/preset-typescript](https://babeljs.io/docs/en/babel-preset-typescript), and [@babel/preset-env](https://babeljs.io/docs/en/babel-preset-env) allow us to use ES6 Modules, JSX, and TypeScript in our tests - [identity-obj-proxy](https://github.com/keyz/identity-obj-proxy#identity-obj-proxy---) is helpful when rendering CSS modules so that we can see the original class names instead of obfuscated ones We also have to add numerous config files such as `babel.config.js` and `jest-setup.ts` which are required to enable all of this functionality. We put our `jest` config in our `package.json` file which works well, but you can also put it in a file named `jest.config.ts` or `jest.config.js`. See the [Jest Configuration Documentation](https://jestjs.io/docs/configuration) for more details about configuring jest.