Notes from a Vite talk
Matt Steele is awesome. He gave a talk on Vite at the January 2023 NebraskaJS Meetup. Here are my notes from the talk.
Vite is a build tool for modern web development. It's a dev server that serves your code via native ES modules during development. It uses Rollup under the hood to bundle for production.
Vite is fast. It's fast because it uses native ES modules. It's fast because it uses Rollup. It's fast because it uses esbuild to bundle for production.
Vite is opinionated. It's opinionated about how you write your code. It's opinionated about how you structure your code. It's opinionated about how you build your code.
- Matt points out that build tools are a pain point and uses some memes to illustrate the pain.
- There are similarities on the java side as well.
- Tree shaking is one reason
- Bundling is another reason
- Compiling the typescript (transpile) is another reason
- Code splitting -- seperating the project so that only the code that is needed is loaded.
- Minifying the code
require() function is another reason -- it's not built into browsers. Made popular by node.js. It's a way to load modules.
- Webpack is a module bundler is been around for a while. e.g. create react app uses webpack. Angular cli does as well.
- What if we used a browser native way to load modules? That's what Vite does. It uses native ES modules. It uses Rollup to bundle for production.
- Vite is fast. It's fast because it uses native ES modules. It's fast because it uses Rollup. It's fast because it uses esbuild to bundle for production.
- Vite is opinionated. It's opinionated about how you write your code. It's opinionated about how you structure your code. It's opinionated about how you build your code.
- Vite is a dev server. It's a dev server that serves your code via native ES modules during development. It uses Rollup under the hood to bundle for production.
- Vite was created by Evan You
- you can use vite with angular, 11ty, react, vue, svelte, and more. It has typescript support out of the box.
- Vite has a great community. 11ty and angular support is community driven.
Very cool project
- Used PartyTown to put the analytics in a web worker thread.
- vite analytics provides a quadtree view of the dependencies. It's a great way to see what's going on.
- Use import as a function to load a module. e.g.
const maplibregl = await import('maplibre-gl')
- Is there PWA support? A: There's a plugin for that: https://vite-pwa-org.netlify.app/
- Snowpack has been depricated in favor of Vite.
Meta Frameworks -- tools that use Vite
- Analog -- Angular
- Astro -- Can use vue, svelte, react, or vanilla js --- a static site generator
- Volar -- Vue
- Vite -- Vite
- Vite Svelte -- Svelte
- Vite React -- React
- Vite PWA -- PWA
- Vim support -- is there too.
Uses some of the more modern native tools -- things built from rust and go. e.g. esbuild is written in go. swc is written in rust. Tradeoff between type erasure vs. type checking.
- JSParty deep dive on Vite is a very nice episode.
Some day maybe
Things I want to try:
Afterwards, things I found on google
- https://www.youtube.com/@BrandonRobertsDev who has written about Vite with Angular and is the creator of AnalogJS. I hope this talk makes it to YouTube.
← Back home