spotifyovercastrssapple-podcasts

Elm and Vite

Lindsay Wardell joins us to talk about Vite and how to set it up for your Elm project.
February 13, 2023
#76

Transcript

[00:00:00]
Hello, Jeroen.
[00:00:02]
Hello, Dillon.
[00:00:03]
Today we've invited a special guest.
[00:00:09]
You might have to help me with the pronunciation there.
[00:00:11]
Yeah, I wish I could help you, but I'm not the one that speaks French in this room.
[00:00:15]
Oh, there's our special guest, Lindsay Wardell.
[00:00:17]
Lindsay, thanks for joining us.
[00:00:19]
Yeah, thanks for inviting me.
[00:00:21]
What are we talking about today, Lindsay?
[00:00:26]
Vite, which is the front-end development tool created by Evan Yu, who is the creator of Vue.js.
[00:00:33]
I wish we had a French speaker on this podcast to help us on how to pronounce that.
[00:00:38]
It would be helpful.
[00:00:39]
Yeah, I'm still surprised by the pun, because I thought, oh, he's going to make some joke about,
[00:00:46]
oh, we need to hurry up and record this or something, like, Vite, Vite.
[00:00:51]
That would have worked, but no.
[00:00:54]
That would have been too clever.
[00:00:56]
In Vite.
[00:00:59]
Going for the lowbrow here.
[00:01:02]
So what is the proper pronunciation?
[00:01:04]
Yeah, well, Lindsay, before we started recording, you said that you were discussing how to pronounce Vite.
[00:01:11]
Yeah, so in a former time, I was a podcaster on the show Vue.js on Vue.
[00:01:16]
And when the Vite framework was originally announced and released, we were talking about it,
[00:01:23]
and none of us could figure out how it was supposed to be pronounced.
[00:01:27]
I think at the time we were saying Vite, because we just couldn't figure it out, but we kept going back and forth.
[00:01:33]
Vite, Vite, should you drop a vowel, should you drop a consonant?
[00:01:37]
None of us actually know French, and the only French word we know is Vue, which I assume we're also pronouncing wrong.
[00:01:42]
Yes.
[00:01:47]
So we just kind of gave up, and the Vite documentation says Vite at this point, and that's how Evan Yu pronounces it.
[00:01:54]
But I just assume that we're all wrong.
[00:01:57]
Well, for Vite, it's not too bad.
[00:01:59]
So the proper pronunciation is Vite.
[00:02:02]
So it's pretty much the same, but the E is shorter, Vite.
[00:02:07]
And Vue is Vu.
[00:02:09]
So that's pretty wrong, I'd say.
[00:02:10]
That's pretty wrong, yeah.
[00:02:12]
I wonder if it's just payback, because Evan Yu is a native Chinese speaker, right?
[00:02:17]
And he's like, all right, you're making me write all this code in English.
[00:02:22]
Now I'm going to make all you English speakers try to poorly pronounce French words.
[00:02:30]
I always assumed it was kind of like to make it sound like his name, Evan Yu, Vue.
[00:02:35]
Yeah, that's cool.
[00:02:37]
I think the original inspiration was he was just trying to find words that described a Vue layer, and he ended up on that one, and it was available on NPM.
[00:02:48]
So at this point, the entire Vue ecosystem is just named after French stuff.
[00:02:53]
That's clever.
[00:02:54]
And it's three letters.
[00:02:55]
Three letters are good for file extensions.
[00:02:58]
Oh, definitely.
[00:02:59]
Yeah.
[00:03:04]
I think you can say Vue.
[00:03:05]
I just say Vue.
[00:03:07]
I think if you're in the know, you can say Vue, but if you use React or Svelte or something, you need to say Vue.js just to be specific.
[00:03:12]
You mean if you're in the React.js ecosystem?
[00:03:16]
Yes.
[00:03:17]
But don't say AngularJS, because that's another thing.
[00:03:20]
Yeah, that's a problem.
[00:03:24]
Thinking about it, and this is off topic from Vite, but Vue did work on AngularJS, and that's part of where the inspiration for Vue came from.
[00:03:29]
So maybe that's part of why Vue is originally Vue.js, and it's since shifted.
[00:03:36]
I don't know.
[00:03:38]
Wait, it's not Vue.js anymore?
[00:03:40]
I mean, if you go to the docs, let me pull it up right now.
[00:03:44]
Vue.js, the pervasive JavaScript framework and guide.
[00:03:51]
Yeah, it just says what is Vue.
[00:03:53]
Okay.
[00:03:58]
Don't mind if you pronounce it Vite, I think it's close enough.
[00:04:01]
I will forgive you if you do so.
[00:04:04]
Thank you.
[00:04:07]
So what is Vue?
[00:04:09]
Sorry, what is Vite?
[00:04:11]
We're not going to talk about Vue on this podcast more than we need to, because that's not what we're here to talk about.
[00:04:18]
What is Vite?
[00:04:20]
So Vite is front-end tooling is how they build it on their site.
[00:04:25]
And I've actually had a hard time coming up with a one-sentence definition that fits into the normal boxes,
[00:04:32]
because what it gives you is first a development environment.
[00:04:36]
So as you're working in your code, it spins up the dev server, you're able to import your code,
[00:04:42]
it does some processing as needed, especially if you're writing Elm code.
[00:04:47]
And then when you go to build, it uses a build process, but it's a completely different build process than what it's using during development.
[00:04:52]
So you could compare it to a bundler, but it's not quite a bundler.
[00:04:57]
And you could compare it to other systems' development environments, but it's not just a development environment.
[00:05:04]
It kind of fits into all of these different sections, kind of like the cracks,
[00:05:09]
especially when you're working in JavaScript, but other languages as well.
[00:05:13]
It fits into the cracks where things aren't as good and makes them much better.
[00:05:18]
And that's why I'm having so much trouble figuring out what it's actually doing.
[00:05:22]
Is it a bundler? Is it this other thing?
[00:05:27]
Okay, it's in between. Gotcha.
[00:05:30]
And actually Vite itself is not a custom bundler.
[00:05:35]
It's using two different bundlers under the hood for doing its job.
[00:05:39]
So during development, primarily it's using rollup for all of your code.
[00:05:44]
If it needs to do any pre-processing, it'll use esbuild, unlike dependencies.
[00:05:49]
But for any of the code that you write yourself, it's using rollup and compiling your code into ES modules
[00:05:55]
so that it can just run natively in your browser without having to be bundled into a single JavaScript file.
[00:06:01]
And then when you're ready to go to production, it will push everything through esbuild
[00:06:07]
and create a single bundle at the end of the day.
[00:06:12]
So Vite itself is not a custom bundler.
[00:06:15]
It's just using other bundlers and putting it together in a unique way.
[00:06:19]
And what are ES modules and esbuild?
[00:06:22]
So esbuild is a tool written in Go for compiling JavaScript.
[00:06:27]
I don't have the specific details in front of me, but I've been told it's very fast.
[00:06:32]
It's one of the up and coming ones.
[00:06:34]
I don't think it's reached a 1.0, but that's not something unfamiliar to us.
[00:06:39]
Fair, fair.
[00:06:41]
That's what esbuild is.
[00:06:42]
It is specifically a bundler.
[00:06:44]
And the other bundler that's used is rollup.
[00:06:47]
Rollup, or I guess you could say rollup.js, was created by Rich Harris of Svelte.
[00:06:53]
And it's going off in its own direction at this point.
[00:06:55]
I don't think he's as involved as it used to be.
[00:06:58]
But that's what's used during the development experience.
[00:07:01]
I find it helpful to compare Vite to Webpack because if you just try to define it,
[00:07:06]
it's kind of like, is it a dev server?
[00:07:09]
Is it a bundler?
[00:07:10]
What is it?
[00:07:10]
But if you think about Webpack, I imagine many of our listeners have used Webpack.
[00:07:16]
And you try to just set up Webpack.
[00:07:19]
You configure Webpack, you write a bunch of config files, you install a bunch of plugins.
[00:07:27]
And then if you're trying to bundle everything, you run the bundle command.
[00:07:32]
And then what if you want to run a dev server?
[00:07:34]
Then there's kind of like maybe another package or plugin you install that helps you get a dev server,
[00:07:40]
but things kind of run differently.
[00:07:42]
So when you compare Vite to that history, I feel like one of the main problems that Vite solves,
[00:07:51]
in contrast to Webpack, is it gives you an environment where you can run a dev server or you can run a build,
[00:07:56]
and it uses kind of the same setup.
[00:08:00]
It will do more minification and things like that for the production build than it does in the dev server,
[00:08:06]
but you can sort of use your same setup.
[00:08:10]
And there's less configuration to write compared to Webpack.
[00:08:14]
That sounds accurate to me.
[00:08:16]
The thought that I have looking at it is in the Elm ecosystem, we talk about JavaScript fatigue a lot when we're talking about JavaScript.
[00:08:21]
So if you're building a React application, you need React, and then you need Redux,
[00:08:28]
and then you need something else.
[00:08:31]
And if you want immutable data, you need something else.
[00:08:33]
And if you want a linter, you need, and so on and so on and so on.
[00:08:36]
Whereas Elm, it's just Elm.
[00:08:38]
And Vite kind of feels the same while remaining a JavaScript thing.
[00:08:42]
If you're needing to build an application, you're going to need a bundler.
[00:08:45]
You're going to need a dev server.
[00:08:50]
You're going to need to do hot module reload, ideally.
[00:08:53]
And that's all very complicated.
[00:08:55]
And we can see how complicated it is in JavaScript because of things like create React app,
[00:09:00]
or in Vue 2.0, they had the Vue CLI, which also used Webpack.
[00:09:05]
So Vite is geared towards solving that problem where you have the dev server, you have the bundler,
[00:09:11]
you have everything that you need just kind of built into one tool.
[00:09:16]
So can you sort of pick up things about your config?
[00:09:20]
For example, if you want to import TypeScript files,
[00:09:26]
then you don't need any special setup because ES build automatically can transpile TypeScript files,
[00:09:32]
and it's built on top of ES build.
[00:09:34]
So it will use your TS config, and it uses various configuration files
[00:09:40]
and these standard conventions to run the bundling. Is that right?
[00:09:45]
That's supported out of the box.
[00:09:46]
Other things are supported out of the box, such as WebAssembly.
[00:09:49]
You can just import a WebAssembly file and start it up in your application, and it works fine.
[00:09:55]
You don't get hot module reload on WebAssembly, obviously,
[00:09:58]
but you can import the WebAssembly file directly.
[00:10:02]
On TypeScript, though, one of the interesting notes is because of how Vite is handling it
[00:10:07]
and passing the TypeScript file to ES build for the compilation step,
[00:10:12]
you don't need any actual type checking in your TypeScript.
[00:10:15]
It's just performing the transpilation.
[00:10:18]
So if you're wanting the lovely type checking that we're used to,
[00:10:21]
you need to set that up in your IDE.
[00:10:24]
Okay, or use a different terminal to run the TypeScript checker.
[00:10:31]
So I'm still confused as to why it's using two different bundlers,
[00:10:36]
one in production and one in development mode.
[00:10:38]
Is it because ES build is only meant for production builds and rollup is meant for both,
[00:10:44]
but it's not as good in production or something like that?
[00:10:47]
The main reason that Vite is using two different bundlers at the moment
[00:10:51]
is because ES build is still under development.
[00:10:53]
It hasn't reached 1.0.
[00:10:55]
So while it's very fast, it can't handle everything at the best efficiency.
[00:11:00]
So for the time being, Vite is using rollup and ES build
[00:11:05]
for two different parts of the experience.
[00:11:08]
The long-term plan is to settle on just one,
[00:11:11]
and that's probably going to end up being ES build because of its speed.
[00:11:14]
But for the time being, they're still having to use the two.
[00:11:17]
There's also the nice benefit with that of having the plugin ecosystem
[00:11:23]
that incorporates Vite specific features, but also the rollup plugins.
[00:11:28]
So if you want to use a rollup plugin in Vite,
[00:11:31]
you can just import it and use it as normal.
[00:11:33]
You don't have to worry about, is this compatible?
[00:11:36]
Because it just is.
[00:11:38]
But only in development mode?
[00:11:39]
It will still work in production.
[00:11:41]
I cannot speak to how it does that magic, but I know it does.
[00:11:44]
Oh, interesting.
[00:11:45]
So that's interesting because I imagine many people do associate ES build
[00:11:51]
with being like a JS and TypeScript transpiler.
[00:11:56]
I have seen in the docs things about CSS files,
[00:12:00]
so I guess it is a general purpose bundler as well.
[00:12:04]
That's interesting.
[00:12:05]
ES build?
[00:12:06]
Yes.
[00:12:07]
I believe that is the long-term goal.
[00:12:10]
I'm not 100% on that.
[00:12:13]
I write applications.
[00:12:15]
Yeah.
[00:12:17]
It seems like a real trend I'm seeing these days in the JS ecosystem
[00:12:22]
is trying to come up with a set of agreed upon standards
[00:12:27]
rather than just everything having bespoke approaches to things.
[00:12:32]
So rollup plugins have a specific format and Vite said,
[00:12:38]
okay, well, there's this sort of plugin API and let's just use that same
[00:12:44]
API. And if we're using that same convention,
[00:12:49]
we can use ES build and for the dev server and everything can play nicer
[00:12:53]
together because they're using the same conventions.
[00:12:56]
Yeah.
[00:12:57]
One of the big pushes was not having to worry about a development
[00:13:00]
configuration and a production configuration.
[00:13:03]
And one of the other niceties was there's a project called Vitest,
[00:13:09]
which is just going to throw the French out the window again.
[00:13:11]
I mean, that's not even a French word at all.
[00:13:16]
It just means you have to pronounce the first bit wrong.
[00:13:19]
It might be a double entendre though, which is not a French idiom, I think.
[00:13:23]
Of course not.
[00:13:27]
But Vitest is intended as a replacement for something like Jest.
[00:13:32]
So instead of having to do all of your testing in Webpack and have a
[00:13:36]
separate configuration for your tests from the application,
[00:13:39]
you can just use your global Vite configuration, write your tests,
[00:13:44]
and everything just works.
[00:13:46]
I saw the name a few times before, Vitest, but I never understood
[00:13:50]
that it was a test framework.
[00:13:52]
I just thought it was, well, Vite means fast, so Vitest is fastest.
[00:13:57]
So it's something to make things faster again or something.
[00:14:00]
Okay, it's a test framework. Gotcha.
[00:14:03]
Yeah, and that was created by Anthony Foo, who is on the core team for Vite.
[00:14:07]
He's been extremely prolific in creating tooling around Vue and Vite.
[00:14:12]
Definitely if you're interested in this ecosystem, I would suggest checking him out.
[00:14:16]
Yeah, it's been extremely active.
[00:14:18]
Vite is just such a well-supported tool these days.
[00:14:21]
I know TurboPack was recently announced, and then there were some somewhat
[00:14:26]
controversial figures that were given.
[00:14:28]
I know Evan, you had some things to say about the methods for coming up
[00:14:34]
with these benchmark comparisons between TurboPack and Vite.
[00:14:39]
It's just like Vite is so well-maintained that I'm not ready to jump onto a new train at this point.
[00:14:47]
Vite seems great, and it seems like an agreed-upon standard, and it uses these standard conventions.
[00:14:53]
So I'm all on board for Vite, personally.
[00:14:56]
Have you tried it on a few projects at all?
[00:14:59]
I use it internally for Elm pages for the V3 beta. I'm using it.
[00:15:04]
There's an SSR mode that tooling authors can use to serve up pages.
[00:15:10]
So yeah, Elm pages V3 comes completely with a built-in Vite server.
[00:15:16]
So you can use it to have SCSS files or tailwind configuration, or import TypeScript code into your entry-point JavaScript file in your Elm pages project.
[00:15:21]
It all just works out of the box.
[00:15:32]
Back in Elm pages V2, I became somewhat disillusioned by the whole webpack world.
[00:15:37]
Some tools, some front-end frameworks like Gatsby and things like that, would expose ways to add your own webpack plugins so you could hook into the webpack internals.
[00:15:57]
That just felt like such a weird inversion where you can mess up internals in a way that could actually break the framework.
[00:16:02]
That didn't feel right.
[00:16:08]
And then it felt like there are so many possible configurations people could build.
[00:16:13]
I just came to this conclusion, Elm pages is going to focus on just compiling your Elm code and setting up everything and just focusing on that.
[00:16:22]
If you want SCSS files, if you want to import TypeScript files, there's a TypeScript compiler that turns that into JavaScript.
[00:16:27]
There's an SCSS compiler that turns that into CSS files.
[00:16:32]
And Elm pages doesn't care how you get your CSS and JavaScript files to it, but that's the only thing it understands.
[00:16:38]
I called it a bring your own bundler philosophy.
[00:16:43]
But Vite completely changed my perspective on that because it came with this sort of standards-based approach where it's like, if you have an SCSS file, you can import it.
[00:16:48]
And you have the thing you need to compile SCSS installed.
[00:16:53]
You don't need to configure it to explain how to transpile SCSS files because that's a standard.
[00:16:58]
You just include an SCSS file in your index.html and it figures that out.
[00:17:03]
Or you include a.ts file in your.html and it figures that out.
[00:17:08]
And then you just compile it.
[00:17:13]
Or you include a.ts file in your script in your index.html file and it figures that out.
[00:17:18]
Or you include a.ts file in your script in your index.html file and it knows what to do with that.
[00:17:23]
And so it completely changed my perspective on that.
[00:17:28]
And I integrated Vite in Elm pages v3 and it's been great.
[00:17:33]
The front end ecosystem in general. I'm really excited to hear how it's in Elm pages v3 and I'm looking forward to trying it more myself.
[00:17:38]
But Vite is being used by Vue, by Svelte, by Solid, by Astro.
[00:17:43]
I think there's some integrations for things like Eleventy as well.
[00:17:48]
So there's a lot of projects that are now using Vite and adopting it in the background and bringing together this whole ecosystem.
[00:17:53]
So that everyone's on the same basic tooling from the start.
[00:17:58]
Then you just add the framework and libraries on top of it that you want.
[00:18:03]
Exactly. Yeah.
[00:18:08]
Yeah. It's a breath of fresh air, especially like, you know, Jeroen and I have talked about this world where you have like,
[00:18:13]
everybody has a custom Babel configuration that gives them like slightly different JS syntax.
[00:18:18]
And then you've got JSX and TSX and then variants on that and all these things.
[00:18:23]
And it's just like, can we just agree like what the basic syntax is and just like not mess with that stuff?
[00:18:28]
So all the tooling can just not need all this customization to just tell it like what syntax is and how things work.
[00:18:41]
And it just feels like the pendulum is swinging back there.
[00:18:46]
Things got a little bit out of hand and now we're like, let's just kind of take a more conventional approach.
[00:18:51]
Yeah. I imagine it's also because the JavaScript community is less intent on shipping new things.
[00:18:56]
Like they're not building a new JSX as far as I know.
[00:19:01]
And it's just like, okay, well people are using JSX. Okay. Let's include it.
[00:19:06]
People are using TypeScript. Let's include it. People are using SCSS. Let's include it.
[00:19:11]
In that way you have a standard because that's what people use.
[00:19:16]
And there are new versions of JavaScript coming on every year.
[00:19:21]
So let's just add support for them whenever they arrive and that's it.
[00:19:26]
So that does make things a lot easier. Yeah.
[00:19:31]
And in the Elm ecosystem, like we've had this for a long time because Elm 0.19 has been released a few years ago and not much has changed since then.
[00:19:40]
So for us, it's very stable as well, but for very different reasons.
[00:19:45]
I think I've come to a point where I'll admit I've only used Elm 0.19.
[00:19:50]
I started in the Elm ecosystem right after it released.
[00:19:55]
So I have not yet seen the pain of having to transfer between versions.
[00:20:00]
Yes. Same here. I think I started looking at it in 0.16 or 0.17.
[00:20:05]
Yeah. 0.16 when there were still signals.
[00:20:10]
0.19 was released like a month before and hasn't changed since.
[00:20:15]
One other piece that we haven't touched on, and I realized Dillon, you asked the question, I forgot to answer it.
[00:20:20]
ESM, which is a huge piece of what makes the Vite development experience so lovely.
[00:20:25]
And as I'm describing this, I'm going to be describing it from a JavaScript perspective primarily because that's where you see the biggest benefit.
[00:20:30]
But this also helps with Elm development as well.
[00:20:35]
During development using Vite, all of the scripts, all of the code, everything is just compiled into standard native ES modules.
[00:20:48]
ES in this case being ECMAScript.
[00:20:50]
You mean that even things that use CommonJS or other formats that you use like require, they get compiled to use import and export syntax?
[00:21:02]
Yes.
[00:21:03]
Good job.
[00:21:05]
During the development process, everything is in ES modules.
[00:21:09]
Rather than the experience that we've had with Webpack, for example, of you have to wait for all of the code to compile before you can even start up your application in the browser.
[00:21:20]
I had an experience at a previous job on a Vue application that used Webpack.
[00:21:23]
Start the application, go and get a snack, come back, it's done, it's ready, now I can finally get to work.
[00:21:30]
Depending on the file that you change, all of that would have to happen again.
[00:21:34]
With Vite, because everything is ES module, it's A, every single file, if you make a change, only that file is replaced in the browser.
[00:21:44]
The browser is acting as the bundler because you're just sending all of the code to it and it's loading things using the native syntax.
[00:21:52]
The other benefit to that is if you're on a page and only some of the code is getting loaded on that particular page, Vite won't bother compiling the rest of it for the time.
[00:22:03]
It will only load the route that you're using and it will only load the code that you're using.
[00:22:07]
Right, and when you're talking about native imports, we should clarify that CommonJS imports are something that bundlers know how to pack up into a bundled asset, but browsers have no idea what require means.
[00:22:24]
If you see require in the browser, it just explodes and says, I don't know what that is.
[00:22:29]
Yep.
[00:22:30]
But if you say import...
[00:22:31]
CommonJS is a remnant from the early days of Node where everyone said, well, we need a way to bundle things and we need modules.
[00:22:41]
And so between the front end needing something like that and the back end needing something like that, the pseudo standard that was developed was CommonJS.
[00:22:50]
But when the TC39 was working on how do we actually standardize this?
[00:22:57]
There is a community standard right now. They felt that going with require and going with the CommonJS syntax was not what best served the JavaScript ecosystem.
[00:23:06]
And so they went with the import syntax that is more modern, we're more familiar with today.
[00:23:12]
So that is what is used in the browser by default.
[00:23:16]
And you could actually do this without a bundler as well.
[00:23:18]
If you wanted to create a section of your code that used ES modules in the browser, no compiler necessary, you would just have to set the script type to module.
[00:23:28]
And suddenly you can import things and you could export things if you really wanted to.
[00:23:32]
And everything would work as you're used to when you're using a compiled language that uses that same syntax.
[00:23:38]
You said you need to change the script type in package.json?
[00:23:43]
No, just in the so if you have an index.html file, and you wanted to import JavaScript as a module, you could just create a script tag and say script type module.
[00:23:53]
Gotcha. Yep.
[00:23:54]
And then you can use your import syntax and use that as you would if you were using a bundler.
[00:24:00]
All right.
[00:24:01]
It's a little different, right? Like if it's a script type module, can you not do things in the top level? Everything has to be like you can export things, but you can't just have top level code. Am I understanding that correctly?
[00:24:15]
I believe there are some restrictions. I don't remember exactly which ones they are.
[00:24:19]
Okay, but it's supposed to be better for tree shaking and things like that, right? Like for static analysis purposes, there are some benefits to ESM standards.
[00:24:29]
There are, if you're using a bundler, yes.
[00:24:32]
The difficulty with ESM, even today as a standard, is that if you're using ESM in production, there will be a waterfall of HTTP requests.
[00:24:43]
Totally.
[00:24:44]
So if you have a large single page application, you're going to fire off JavaScript request after JavaScript request until the whole thing is loaded that you need. And that's not really ideal, even today.
[00:24:55]
Wasn't that what HTTP 2 was meant for? Solving that kind of issues?
[00:25:00]
I think the main problem is that if you load up your index.html file and it references a single JavaScript file, you fetch that file, but then it's going to reference other files.
[00:25:10]
So it's not that you can't do the requests in parallel, it's that it doesn't know what requests to make.
[00:25:14]
Yeah, of course.
[00:25:16]
Yeah. And there do exist plugins that like hoist module preload directives to figure out what that waterfall is going to have and then add preload directives to tell you.
[00:25:31]
But yeah, generally, people just in the production build just turn everything into a single bundled asset instead, or well, not necessarily a single one, but they chunk the assets rather than just having everything be ESM imports.
[00:25:48]
So if somebody wants to try using Vite with Elm, what is the minimal thing they can do to get started with that? And what's the simplest way they can get started with that?
[00:26:01]
So if someone wanted to take Vite and just run, for example, npm create vite, set up a new project, whether they're using another JavaScript framework or just vanilla JavaScript, the first step that would need to be done is install the Elm plugin.
[00:26:18]
And that plugin is just called Vite plugin Elm. And it is lovely. I've been using it for some time on my own projects. I'm sure you're familiar with it as well, Dillon.
[00:26:27]
Then in your Vite config, there's a Vite.config.js file. And you have two, as a bare minimum, you need two imports. One is import define config from Vite.
[00:26:39]
And that gives you the configuration file and also gives you TypeScript typing, which is helpful as you're working in that file. So you don't need to be constantly referencing the documentation.
[00:26:49]
And then you need to import the plugin itself. And then as far as the configuration goes, the way the file is structured, you just say export default define config, which is a function, takes an object.
[00:27:00]
And as a key, you say plugins, which takes an array, and then you invoke the Elm plugin as a function inside of that array, and you're done.
[00:27:08]
That's all you need to do to integrate Elm into a Vite application. From there, you of course need to run Elm init, create your Elm file and import it into the JavaScript. But you can import it as if it were JavaScript at that point.
[00:27:19]
You can just import Elm from main.elm and instantiate your application as you normally would. So that would be the bare minimum to get Elm working inside of Vite.
[00:27:30]
What I would recommend as a simple way to do that instead is, this is a shameless plug, by the way, I have a template for creating Vite applications using Elm that includes nice tooling such as Elm test and Elm review and some example code to go with that as well.
[00:27:47]
So that would be my recommendation. And that is just called Vite template Elm. And you can find that on GitHub, lindsaykwardell slash Vite Elm template. Sorry, I said Vite template Elm and it's Vite Elm template. I'm good at knowing what my own things are called.
[00:28:01]
Yeah, that's great.
[00:28:04]
What we tend to do is just name things the easiest way. The only question is like, which order is it?
[00:28:10]
Yeah.
[00:28:12]
I mean, you could have said template Elm Vite and that would be terribly wrong. But we would still get it.
[00:28:18]
Yeah, it's got to be Vite first. And I think I went with Elm second because that's the language. I don't know. Yeah, so that would be the simplest way to get started. So you get the hot module reload, which actually works with Elm as well. It's lovely. I really appreciate it.
[00:28:32]
You also get the integration with Vite static asset handling. Vite not only can handle TypeScript and JavaScript and WebAssembly and CSS, but you can also import images straight into it. And there's a nice little plugin. It's an Elm package that will prefix things properly so that Elm code gets compiled to JavaScript code that actually handles the assets in a way that Vite likes.
[00:28:53]
You can do it manually. It's just a string, but it's nice to have something a little stronger. The tooling is all installed via Elm tooling, so you can spin things up in your CI CD. So you get Elm, Elm format, Elm JSON, Elm test. You get Elm review and unit test examples. And there's a GitHub Action CI for running tests, just as an example. So that's what the template includes. It's not intended to be like, this is the best solution, but this is a simple solution that shows everything you would need.
[00:29:21]
Yeah, it's pretty exciting how little boilerplate there is for getting started with something that is not a cute tool that sort of gets you started and then you outgrow. It's a very simple setup that gets you up and running quickly. But then it's the tool that everybody uses now that has a ton of support and can do whatever you grow into doing later. So that is a breath of fresh air, for sure.
[00:29:50]
I mean, Webpack also did that, but you had to configure it a lot.
[00:29:55]
Yeah. My inspiration for this template was actually using the Create Elm app, which is built on Webpack. I had an application written in that and I kept running into situations where I felt like I needed to eject and then handle the Webpack config myself, and I just really didn't want to. So when the plugin came out that supported Elm and Vite, I immediately ported the application over to Webpack.
[00:30:19]
And then backtracked to a template that I could reuse in future applications.
[00:30:23]
Yeah. Do you also have the concept of ejecting in your template?
[00:30:28]
There is nothing to eject. The nice thing about Vite is everything is self-contained, but if you need to override something, it's very easy to do so. And that philosophy carried over from Vue.js as well, where you had a config. Yes, it used Webpack, but you didn't need to worry about ejecting. You just extended it with your own stuff.
[00:30:49]
For those who don't know, ejecting is when you use Create Elm app or Create React app, you run commands through that CLI, like Create Elm app, Create Elm app run, Create Elm app start or whatever.
[00:31:04]
But then whenever you did something too custom, you would have to opt out of using Create React app, Create Elm app. And at that point, you have to eject and you're on your own. And I found it always very scary, like, oh, what if I want to do something custom?
[00:31:22]
Oh, now I have to eject. Oh, now there are so many things that were handled for me automatically that are not anymore. So I'm really happy that you don't have that concept. It's just like, these are the scripts and you do whatever you want. And they're all simple.
[00:31:39]
Yeah.
[00:31:40]
That's really nice.
[00:31:41]
And if you want to extend it with a JavaScript framework, like Vue or Svelte or Solid or React or something, it's really easy to do so because it is just using Vite. I have the opposite problem, Dillon, where I want people to have all the foot guns.
[00:31:55]
Because I don't want to lock it down. I want people to play with it and explore and feel comfortable with Elm, interacting with the tooling that they already have.
[00:32:04]
Yeah. I mean, the beautiful thing is like all these Create React app, Create Elm app, they were addressing a real need, a real pain point at the time, which was that Webpack was this, you know, very verbose configuration that like you go and copy paste these like very complicated setups just to like, tell it you want like raw imports for CSS.
[00:32:33]
Or you want like, you want it to transpile Elm and things would break frequently. And you're just like, I just I just want to like import an Elm file. I just want to import SCSS.
[00:32:44]
Like, can I just do that? And it's like, yeah, well, here's this configuration. But there's this one thing that's kind of broken in it. And it made things more customizable than they needed to be.
[00:32:54]
And so it gave you an overly general purpose way of configuring things, which most of the time isn't what people want. They just want to use SCSS. That's, that's all. They just want to import Elm. That's all. And so now...
[00:33:07]
I don't know if you can tell that Dimon had horror stories about Webpack.
[00:33:12]
Well, Elm Pages v2 was built as a Webpack plugin. So I have horror stories. It was painful. It was very painful. Writing custom Webpack plugins was very sparsely documented and error prone and difficult to debug.
[00:33:34]
It was like, honestly, probably the hardest technical accomplishment of my career was getting that thing working. It was... And I'm not proud of that. It just was.
[00:33:50]
But so like create React app and create Elm app were addressing a real pain point, which is just you needed a simpler abstraction for how to configure a basic Elm app or basic React app.
[00:34:04]
And then Eject was, well, let's address the problem that you might outgrow that and need to do something more custom. But if you don't, then we can hide some of that complexity from you.
[00:34:16]
But now with Vite, it's like, well, there's really not that much complexity to hide. You just use the Elm plugin and now you can import Elm.
[00:34:23]
Like we don't need to create a wrapper tool that abstracts the complexity of the basic setup for that for you.
[00:34:31]
So, man, I think it's a pretty good time in the web ecosystem, I would say. I think we've really gotten some nice, nice tools.
[00:34:41]
So, yeah. Are there any other kinds of assets that Vite can process that you enjoy using, Lindsay, when you're working with Vite?
[00:34:50]
Primarily what I've used has been CSS, TypeScript and images. So I haven't dug in a ton to all of the flexibility that it offers there.
[00:35:00]
I did play around a bit with WebAssembly and compiling Rust and running that inside of Vite. That was really fun.
[00:35:06]
I don't know Rust well enough to make use of it, but I did some simple addition and called it in JavaScript. So that made me happy.
[00:35:13]
One of the other features, though, that I really like that ties into this use of standards is using web workers inside of Vite.
[00:35:22]
So when you instantiate a web worker, there's the web standard way of doing it. And Vite just supports that standard.
[00:35:31]
So if you want to instantiate a web worker, you just call it the exact same way. Or there's a special syntax as well that they offer from a previous version of Vite, but it's no longer the recommended way.
[00:35:42]
So you could call new worker just like you would if you were in a standard JavaScript file, reference the URL for your worker JavaScript.
[00:35:51]
Or you can import worker from worker and then append it with a query parameter of worker.
[00:35:57]
And you want to give people a short introduction to what a web worker is?
[00:36:02]
Absolutely. Web workers are if you have a long running or high calculation task in JavaScript or just the front end in general, and you need to run that.
[00:36:13]
Typically, if you're just doing it in the main application, you're going to cause issues with the browser.
[00:36:19]
Example of this can be CSS not updating properly if somebody moves their mouse and the hover animation doesn't change, that could be what's happening.
[00:36:27]
The goal of a web worker is to get it off of the main thread and into its own subsection of the browser.
[00:36:33]
And then you can pass messages to and from the web worker just via JavaScript.
[00:36:38]
So, for example, on my blog, I wrote a blog post about this where you could have two Elm applications, one being the view layer and one being the web worker.
[00:36:49]
And these two Elm applications are just communicating via this messaging protocol and then passing the messages into their ports.
[00:36:55]
So it becomes an effective way to have two Elm applications talk to each other if you need to do complex calculations inside of Elm.
[00:37:01]
Yeah, Elm's architecture is actually very interesting for this because of the way it separates the sort of DOM mutation.
[00:37:10]
And because of the whole virtual DOM diffing and everything, conceptually, you can really separate the state part of it from the DOM updating part of it,
[00:37:21]
which is basically what web workers can't touch the DOM, but they can run code.
[00:37:27]
And it's a good kind of way to split things up.
[00:37:30]
Yeah, and the fact that Elm has platform.worker that doesn't require looking at the DOM,
[00:37:36]
so you can just render that in a headless environment such as a worker or a node.
[00:37:41]
But you can use that to instantiate an Elm application that can then just communicate via ports.
[00:37:47]
It takes an input and that's all of the inputs to its update function.
[00:37:51]
Yeah, I think this could definitely be a really interesting thing to experiment with.
[00:37:57]
I could imagine at a framework level abstracting this way, especially because I think there's a clear segregation between the processes.
[00:38:06]
So you have to use array buffers to send messages back and forth, which is a little bit awkward.
[00:38:14]
Can you send JSON as well, maybe?
[00:38:18]
I believe you can just send JSON.
[00:38:20]
You can send JSON too? Yeah.
[00:38:22]
My side projects in Elm is a turn-based strategy game and I'm using a web worker to do the AI calculations.
[00:38:28]
Nice.
[00:38:29]
So I just send the game state over as JSON.
[00:38:31]
So from Elm to Elm again?
[00:38:34]
Yes.
[00:38:35]
Because it's too slow to have it in the Elm main thread?
[00:38:39]
Yep. The problem I was having in the game context, in a late stage of the game,
[00:38:44]
there were a lot of pieces on the board, there was a lot of options available to the computer,
[00:38:48]
and it would have to cycle through all of the cells, all of the units, all of the combinations of units,
[00:38:54]
and make a decision on what to do.
[00:38:56]
And when it was doing that in the main thread, all of the CSS would stop working.
[00:39:02]
So if you tried to do anything, or even just open the menu and say, I'm done playing, get me out of here, you couldn't do that.
[00:39:08]
So I switched that all to being sent via JSON to a web worker,
[00:39:14]
and then just decoding it back into Elm, performing the calculation, and then shipping it back.
[00:39:19]
So it can still take time, because it's having to do all those calculations, but it's not blocking the CSS anymore.
[00:39:25]
That would be really interesting if there was some abstraction where you could basically say,
[00:39:30]
here's a message to send back when this long-running computation is done on a web worker thread.
[00:39:37]
And then you could say, I'm awaiting the AI response for this, and I'm going to show this as loading
[00:39:47]
until I get that message and update my model, having gotten the computation from the AI's prediction or whatever.
[00:39:54]
Could be really interesting.
[00:39:56]
So Vite, why do we need a special syntax for importing something as a web worker with Vite?
[00:40:03]
How does it help us with that?
[00:40:05]
I believe the original problem was how Vite was doing its compilation to ES modules.
[00:40:11]
The worker syntax was just not playing nicely with how the bundling was happening under the hood.
[00:40:18]
So the version I was working with at the time, I believe, was Vite 2.
[00:40:23]
Vite 4.0 has now released, and looking at the docs, they now support the standard new worker syntax.
[00:40:30]
And when you were talking about this, importing this WebAssembly Rust,
[00:40:35]
was Vite actually running the Rust compilation step for you, or was it importing Wasm that you had compiled from Rust?
[00:40:44]
There is a plugin for Vite that will compile Wasm.
[00:40:48]
However, it still has to be a separate step from running the Vite dev server.
[00:40:53]
But you are using the Vite config at that point, you're using the standard tooling that you're using for the rest of your application.
[00:41:00]
You just need to compile that first, then start your dev server.
[00:41:04]
So when I was playing with it, I had a separate step before actually instantiating the Vite dev server.
[00:41:10]
But I could just run npm run dev, and I didn't have to think about it.
[00:41:14]
I don't understand. How come you need to have a separate step for that?
[00:41:17]
It may have changed, but the last time I looked, the Wasm file isn't actually generated until you do the compilation.
[00:41:26]
Otherwise, you're just writing Rust files and you're in the Rust environment.
[00:41:30]
So when you're compiling Rust, you need to say, I'm targeting WebAssembly,
[00:41:34]
and that's what generates the Wasm file for you to import inside of Vite.
[00:41:38]
I thought of the way that Vite worked is you have an index.html file, and you have a bunch of imports.
[00:41:46]
And if you import something like something.wasm, then it figures out, okay, I know this file, and it comes from this step.
[00:41:55]
Is that the problem? It doesn't know which task makes it?
[00:42:01]
I believe if you updated the Wasm file, it would work fine.
[00:42:05]
The setup that I was using had it as part of spinning up the dev environment.
[00:42:10]
So I don't think it would be hot reload in that sense, because WebAssembly can't do that, I believe.
[00:42:17]
But you do get the benefit of if you do a refresh, then it's there.
[00:42:21]
I wonder if you would be able to set up like a Vite plugin to say when I import a Rust file, compile it to Wasm and then import that.
[00:42:33]
I would love that.
[00:42:37]
So you mentioned that there is hot reload even for Elm.
[00:42:40]
Can you explain what it does exactly and how well it hot reloads?
[00:42:46]
Sure. So for people less familiar, hot module reload is if you are working...
[00:42:52]
I'm going to use JavaScript as an example.
[00:42:54]
If you're working in a JavaScript application, and you have three different files that you're working in, and you change one of them,
[00:43:01]
hot module reload first will grab that new code that you've written, load it into the browser.
[00:43:06]
But also execute that and make the change.
[00:43:09]
So if you're changing what the UI should look like, it will make that change for you.
[00:43:13]
If you're changing the logic of a function, it will make that change for you.
[00:43:17]
It will replace the code, and you don't have to refresh your entire page.
[00:43:21]
I feel very spoiled by this feature whenever it's available.
[00:43:24]
I've tried working with other frameworks that don't have it, and it makes me very sad.
[00:43:28]
So where it comes in handy in Elm is the same.
[00:43:32]
If you're working in an Elm application, and you just change the logic of a function, Elm will hot reload and just replace the logic of the function.
[00:43:39]
The downside where it comes to Elm is if you're modifying functions in the same file where you define what your model is,
[00:43:49]
or where the core of your application is, it will hot reload that whole thing.
[00:43:53]
So if you are working in an Elm application with a single file, and you make a change, it will reload the entire file.
[00:44:01]
So your entire application will initialize again.
[00:44:04]
So if you are breaking your Elm application down into separate files where you've got a file per type, for example,
[00:44:10]
and that type has certain functions, and you make the changes to the file of that type, that file will reload, your code will continue to run,
[00:44:19]
your model will still be there, everything will be in the state that it was.
[00:44:23]
But now the new functions will be available that you just wrote.
[00:44:26]
So it works with Elm, and I still highly appreciate not having to hit the refresh button on my page myself.
[00:44:33]
But there are some gotchas because of how Elm works and where the model is stored.
[00:44:38]
Right, yeah. I think I remember Simon Nadal talking on this episode for Elmwatch about techniques he made to improve that.
[00:44:48]
But yeah, this sounds pretty hard to do. Like if your model changes, for instance, then you have to refresh the whole page anyway.
[00:44:57]
Although now that you mention it, I do remember at one point changing my model, referencing the key, and seeing a null appear on screen, which was very weird.
[00:45:05]
Yep, that's not wanted.
[00:45:09]
Yeah, I find most of the time, the reason I want hot module reloading is if I'm tweaking a view,
[00:45:20]
I don't want to have to keep finding the state I was in that shows that view.
[00:45:26]
But if I'm changing my model and the way that messages are flowing through the system,
[00:45:32]
then I'm fine just refreshing and starting that process over. So it usually works pretty well.
[00:45:39]
Yeah, I've been pretty happy with how the hot reloading works in Elm. Similar experience.
[00:45:45]
It helps a lot more when you're working on the UI layer.
[00:45:48]
But again, just not having to think as much about, am I looking at the correct version of my application?
[00:45:54]
Did it refresh? Did I refresh the page?
[00:45:57]
It helps a lot just with the process of building an application. So you can look at your code, rate the changes, switch back to the browser.
[00:46:06]
And because of how fast Vite is, typically it's already done by the time you get back.
[00:46:10]
You're not alt-tabbing fast enough. That's it.
[00:46:13]
I need to work on my alt-tab game. That's what I need to do.
[00:46:18]
Why might someone consider alternatives to Vite? Maybe you're all in on Vite, but I'm curious.
[00:46:27]
Do you think there are use cases where someone would want to not use Vite with Elm?
[00:46:32]
That's a good question. I don't. So I will fully admit I am all in on Vite.
[00:46:38]
I came from the Vue ecosystem. Evan, you created this. I really appreciate his work and I just kind of stick with it.
[00:46:45]
The fact that the rest of the JavaScript ecosystem has gone in this direction as well gives me added comfort in that.
[00:46:50]
That said, I think it's perfectly reasonable to take a different course if that is what feels more comfortable.
[00:46:57]
And I think that's what it comes down to, is comfort.
[00:47:00]
So, for example, there's Parcel, which you don't even have to use a plugin to get Elm working. Elm just works.
[00:47:07]
There's tools like ES Build, or please don't use Webpack, but there's Webpack too.
[00:47:14]
If you really want to go in that other direction and not down this path,
[00:47:22]
I think there's some kinds of developers that really prefer that configuration of all the nitty gritty over having something that's pre-configured that they can update.
[00:47:31]
The other big one is if you want to use ES Build and you don't want all the other benefits of Vite, you could just use ES Build, for example.
[00:47:40]
I know plenty of projects and companies that are doing just that if they want to use Vite.
[00:47:45]
Whether it's Elm or not, ES Build is a wonderful tool on its own. It's still in development, but it's pretty good.
[00:47:51]
So if you didn't want all the extra goodies that come with Vite, they don't benefit you for whatever reason.
[00:47:57]
It's perfectly reasonable to just go with something more lower level and just get a bundler.
[00:48:02]
I think those would be the main reasons I would go with something else.
[00:48:06]
The only one that I knew about and used sometimes was Parcel.
[00:48:12]
Just because it worked without any configuration or so.
[00:48:16]
And the alternative at the time was Webpack.
[00:48:20]
There's one that works without a configuration and the other one that doesn't work with a lot of configuration.
[00:48:25]
So the choice was quite easy.
[00:48:27]
I wouldn't be able to tell what the difference is between Vite and Parcel.
[00:48:35]
I think in many ways that's a good thing.
[00:48:38]
If they do the same thing, yeah.
[00:48:41]
They do pretty much the same thing for what you need.
[00:48:44]
And so it comes down to a preference, which one feels more comfortable to use.
[00:48:47]
I think for me, the big reason I lean towards Vite besides I came from the Vue ecosystem is
[00:48:54]
I'm jumping between other frameworks a lot of the time for other side projects.
[00:48:58]
And being able to, for example, in a Nuxt application, Nuxt.js, it's a server-side rendering framework for Vue.
[00:49:05]
Because it's using Vite, I can just import the Elm plugin.
[00:49:09]
And now I have the power of Nuxt on the backend and the components if I really want to.
[00:49:15]
And then for anything that feels like it should be in Elm, I can just render that in Elm instead.
[00:49:20]
And I can just mix and match a whole lot easier.
[00:49:22]
And similarly, going the other direction, if I'm a Vue developer or I'm a React developer
[00:49:27]
and I want to try out Elm, or I want to try out Svelte, or I want to try out whatever, but we're an Elm podcast.
[00:49:34]
If you want to try out something else and you're using Vite already, it's as simple as just getting started.
[00:49:41]
If you're using Elm, just plug it in.
[00:49:42]
If you're wanting to use Vue, just plug it in.
[00:49:45]
And then you can start using that thing, whatever it is.
[00:49:48]
And the fact that so much of the ecosystem is already built on that, you've got Nuxt, you've got Astro, you've got SvelteKit, SolidStart.
[00:49:56]
There's just so much that's built into that.
[00:49:59]
I really like the ability to jump between the different tools and the different frameworks and the different applications.
[00:50:03]
And it's all the same configuration underneath.
[00:50:06]
And I know what I'm getting into.
[00:50:07]
So that's when I'm evaluating a new project such as Elm Pages v3, I'm looking to see what is it using under the hood.
[00:50:15]
And, oh, it's Vite. Awesome. I'm probably going to use this.
[00:50:18]
Yeah. I was adding something to the docs site for Elm Pages for basically like, I think I even saw some GDPR thing about some litigation because people were loading Google fonts directly.
[00:50:37]
And it was violating people's privacy because it was unnecessarily pinging Google servers when people loaded a page just to load a font.
[00:50:47]
And I'm like, wow, that's been like this standard way I do things, just load a Google font.
[00:50:53]
And for a long time, people said, well, it's a good practice because you cache the font.
[00:50:59]
So if somebody else has loaded it with Google fonts, it will be in their cache.
[00:51:02]
But actually, that no longer happens on browsers because they realized that that was like a fingerprinting vector that could let people identify a user based on which assets had been cached on their site.
[00:51:14]
So caches are sandboxed by domain.
[00:51:17]
And so you no longer have even that benefit.
[00:51:20]
Plus, when you have to connect to another domain, you have to do the whole handshake and open up that connection to another domain.
[00:51:27]
So it's faster if you load the asset from the site that is being hosted at.
[00:51:33]
And so how do you how do you do that?
[00:51:36]
Install a single Vite plugin, tell it the Google fonts you have, and then it just knows how to do it.
[00:51:43]
And it's so easy.
[00:51:44]
And I can do that now in the Elm pages doc site, which, of course, if it was not written in Elm pages, that would be embarrassing.
[00:51:51]
It's written in Elm pages.
[00:51:53]
But I just open up the Vite config and then add that plugin to for downloading Google fonts.
[00:51:59]
And it's so easy to use.
[00:52:01]
So it's pretty cool being able to hook into this like vibrant ecosystem, which like everybody has decided is a good idea right now.
[00:52:09]
So when do you get tracked now?
[00:52:11]
Is it when you build the application?
[00:52:14]
Google knows when you run your build.
[00:52:16]
Yeah.
[00:52:17]
Okay, good.
[00:52:18]
Yes.
[00:52:19]
We wouldn't want to take that away from them, right?
[00:52:23]
As long as they can't shut it down, that's fine.
[00:52:27]
Google knows if you've been bad or good, so be good for goodness sake.
[00:52:30]
Oh, no.
[00:52:34]
I mean, it's true, but oh, no.
[00:52:39]
On Vite real quick and the integrations, I just pulled up an article written by Patak, who's one of the core developers on Vite at this point as well.
[00:52:48]
And there's just so many integrations that Vite has that I didn't even remember as we were talking about it.
[00:52:54]
So, for example, there's plugins for Ruby.
[00:52:56]
So if you've got Ruby on the back end, typically you're going to be using something like Webpacker to bundle your JavaScript as the default.
[00:53:03]
So there's a way to replace that with Vite, and you can just have a really nice tool for JavaScript on the front end.
[00:53:10]
And same for Laravel.
[00:53:12]
There's a plugin for Laravel that lets you just use Vite instead of its equivalent of Webpack.
[00:53:16]
And there's also tools like Cypress or Storybook that are more development tools.
[00:53:22]
You've either got your end-to-end testing or your component library or something.
[00:53:26]
But it can all use Vite across the stack.
[00:53:29]
You don't have to worry about these separate configurations.
[00:53:31]
You don't have to worry about which environment to make in and trying to get the tools to talk to each other.
[00:53:36]
It's just a streamlined way to use the same configuration and the same expectation of how the code works across your entire code base.
[00:53:45]
Just so I don't misunderstand it, Ruby doesn't get compiled to ESM, right?
[00:53:51]
Correct. That's just Ruby on Rails doing Ruby on Rails things.
[00:53:55]
Okay. So Vite is not only compiling for or bundling for a front end, but it's also able to run servers, right?
[00:54:03]
Is my understanding correct now? Because Laravel is a backend technology as far as I understand it.
[00:54:10]
This is more an integration so that as you're working with Ruby or Laravel, rather than having to compile your JavaScript via Webpack or via something else or not at all, you're integrating Vite into that experience.
[00:54:23]
Okay. Right. Which means if you try to download hello.scss, or when you render your HTML in Ruby, I'm assuming it has to post-process that with Vite.
[00:54:41]
So it's some setup that runs on the server to make sure it has those assets, I'm assuming.
[00:54:46]
Yep. Even in production?
[00:54:48]
In production, it's using a bundle at that point.
[00:54:50]
Okay.
[00:54:52]
That said, because you mentioned Vite on the server, there is Vite Node or Node Vite. I think it's Vite Node.
[00:54:57]
And that's what Vitest uses in order to run Vite on a Node environment for running unit tests.
[00:55:04]
But it's not really intended, at least for the time being, as a solution to write a server in.
[00:55:09]
So nobody's going to be writing blog posts on how to set up Express using Vite Node.
[00:55:14]
Are you sure about that?
[00:55:16]
They might now, but...
[00:55:17]
I mean, if there's one thing I know about JavaScript developers, it's if it's possible to do it, they're going to do it.
[00:55:26]
And that's fair.
[00:55:28]
For better or worse. Sometimes it's better.
[00:55:31]
Sometimes it is.
[00:55:33]
All right. Well, Lindsay, do you know any good resources for getting started?
[00:55:38]
Do you have any recommendations for things to watch or listen to or read if somebody wants to learn more about Vite and get started?
[00:55:46]
I think that's going to be a nuanced answer depending on what you're looking for.
[00:55:50]
If you just want to get familiar with Vite, I would just go to the website, vitejs.dev, and kind of just read through, find what's interesting for you.
[00:55:59]
There's the awesome Vite repository that has an amazing list of resources that are using Vite.
[00:56:05]
A lot of it's going to be about Vue and React, but there's a little bit of Elm in there.
[00:56:10]
And I think the third thing I would suggest is on YouTube, last year in October was ViteConf 2022, where I gave a talk on the same thing about using Vite and Elm together.
[00:56:22]
And I will admit that talk was directed more at people who aren't familiar with Elm than people who aren't familiar with Vite.
[00:56:28]
But you can check that talk out as well as all of the other talks.
[00:56:32]
It was a 24-hour conference.
[00:56:33]
There was a lot of content in there about all the different frameworks, all of the different tooling, and how this ecosystem is really shaping up and coming together.
[00:56:41]
So those would be the resources I would point at first, and then just kind of explore and see what feels good.
[00:56:47]
Amazing. And where can people follow you?
[00:56:51]
I am on Twitter at lindsaykwardell.
[00:56:54]
I am also on Mastodon at lindsaykwardell at mastodon.social.
[00:56:59]
Fabulous. All right.
[00:57:00]
Well, Lindsay, it was a pleasure having you on. Thanks so much for coming on the show.
[00:57:03]
Thanks for inviting me. This was great.
[00:57:05]
And you're in. Until next time.
[00:57:07]
Until next time.