News for hackers. Stuff that matters.
Re:Vite – Next Generation Front End Tooling by BiteCode_dev on Sunday July 03, 2022 @12:46PM (#31969052)
Terrible landing page for an otherwise excellent tool.

It sets up JS transpiling and bundling for you in an easy way, then provide a server with pretty fast hot reload.

This solves 2 problems:

- the complicated js project stack is now simple to setup, unlike with webpack

- saving and seeing the result of your coding is now almost instant, unlike with CRA

It's a joy to use, given that it's from VueJS author, and I highly recommend it to anyone that has a lof of frontend to do.

Re:Vite – Next Generation Front End Tooling by SCLeo on Sunday July 03, 2022 @12:54PM (#31969097)
I have been using parcel for web development because I thought webpack is very difficult to use. However, for my latest personal project, I tried webpack. To my surprise, I found webpack 5 much simpler to use then I thought it is (significantly easier than make or gradle, the complexity is not even on the same level). Everything pretty much worked out of box now. All I had to do was to copy the starting template for typescript from their website (~20 lines, half of which are open/closing brackets) and copy the setup for dev server. HMR, code splitting via dynamic imports, etc. all worked without any setup.
Re:Vite – Next Generation Front End Tooling by dmix on Sunday July 03, 2022 @02:25PM (#31969834)
Webpack is probably fine for new or small projects. It's when you've been using it for a while, do anything complex, or worst of all your framework libraries update then you have to update Webpack which is a nightmare.

Ive had Webpack break more of my deploys than any other piece of software in the last 3 years.

Vite was basically a plug and play replacement (almost zero config) and I also got to drop Babel, so that meant replacing about 12 packages in my package.json and who knows how many in Yarn.lock (Mostly babel and webpack plugins) with 2 vite packages. It's much faster at builds and the chunking of small js files seemed more intelligent and better integrated with Vue.

Re:Vite – Next Generation Front End Tooling by SparkyMcUnicorn on Sunday July 03, 2022 @02:17PM (#31969771)
Vite is incredibly fast compared to Webpack.

I didn't really know how much time I could have been saving, and I never even thought of Webpack as slow.

Re:Vite – Next Generation Front End Tooling by kitd on Monday July 04, 2022 @01:52AM (#31973856)
IIRC Vite wraps esbuild, which is written in Go and very fast.
Re:Vite – Next Generation Front End Tooling by sebdufbeau on Monday July 04, 2022 @10:06AM (#31977171)
You can use esbuild with webpack via esbuild-loader, but what makes Vite so fast is mainly the strategy of pre-bundling dependencies when running the dev server, this makes hot starts and hot reloads incredibly quick.
Re:Vite – Next Generation Front End Tooling by shepherdjerred on Sunday July 03, 2022 @01:39PM (#31969440)
Vite is just a few lines, and it’s a much better experience than webpack
Re:Vite – Next Generation Front End Tooling by tpict on Sunday July 03, 2022 @04:29PM (#31970739)
Last time I checked NPM the weekly downloads were still heavily slanted in favour of version 4. I wonder if that plays into perception of it.

At work, an engineer in a different team recently recommended we switch to Vite because it’s “so much faster”. Warm builds are 700ms with our very uninteresting Webpack 5 config. It’s hard to imagine that the cost of reconfiguring our entire build would be worth it.

Re:Vite – Next Generation Front End Tooling by unsupp0rted on Sunday July 03, 2022 @01:36PM (#31969414)
> pretty fast hot reload

An understatement to be sure: you can set VS Code to auto-save every 1 second and that way whatever you type instantly appears via Vite's Hot Reload in your dev browser. No waiting multiple seconds for a recompile.

It's game-changing workflow (for some tasks).

Re:Vite – Next Generation Front End Tooling by boredtofears on Sunday July 03, 2022 @02:09PM (#31969707)
I dunno if it's just me, but I've always found live reload to be an overstated benefit. I usually have a mental model of what I'm trying to code that I don't want to check until it's at a specific state - the seconds it takes to press reload doesn't really add up to that much.

I'd say it's more beneficial for CSS styling but I usually mock up my changes in the dev inspector and then copy it over anyways.

Re:Vite – Next Generation Front End Tooling by aidos on Sunday July 03, 2022 @02:24PM (#31969826)
Exactly that though. For a SPA you’re going to have a bunch of state loaded and you don’t want to refresh. If you’re using something like tailwind where you’re transpiling your css too then it’s a major boon to have it hot reloaded.

I’ve found vite to be an awesome dev experience.

Re:Vite – Next Generation Front End Tooling by drschwabe on Sunday July 03, 2022 @09:55PM (#31972729)
Not just you.

Hotreload can be handy to some extent, annoying in others - I like to preserve state of given app including what the dom looks like + the window/memory state in devtools. Iterate in code, refresh, then compare. You can do that with multiple browser tabs for example. But not with hotreloading; each tab will re-render/reload the global window state.

Re:Vite – Next Generation Front End Tooling by intrasight on Sunday July 03, 2022 @02:04PM (#31969668)
Game-changer perhaps in a bad way ;) We're losing the art of writing solid code and instead flail with the "hot reload" crutch. I miss the days of punching cards and submitting a deck to be compiled and run - at least in terms of it forcing me to verify my work ahead of time.

And yes - I'm (mostly) kidding. But I did write my first programs on punched cards at a university course while I was still in grade school. Probably the last generation of programmers to experience that discipline.

Re:Vite – Next Generation Front End Tooling by nightski on Sunday July 03, 2022 @02:49PM (#31970006)
We are also writing far more complicated software. Punch cards didn’t have to support thousands of different devices, resolutions, screen densities, input methods, etc. It’s a totally different world.
Re:Vite – Next Generation Front End Tooling by crdrost on Sunday July 03, 2022 @03:38PM (#31970357)
That's totally fair but the tooling is still not where you'd like it.

In theory, there's no reason that you shouldn't be able to backtrace from the website to the filesystem. If you can do that, then your "it reloads every second" becomes even faster, it becomes WYSIWYG, you are writing in the live constantly-refreshing UI. Well, almost: your text editor has Undo and Git and your web browser doesn't. But we could build those into the browser. Heck, Redux is basically Git except without any standardized verbs, just give Redux some standardized verbs for tracking revisions in a living app and you've got everything you need.

If you follow that trend to its logical conclusion ("OK I want a special way to ctrl-click or right-click or something to edit the HTML of a component I see") you eventually get Smalltalk, and we're finally back as productive as we could be in the 70s :)

Re:Vite – Next Generation Front End Tooling by jjeaff on Sunday July 03, 2022 @04:56PM (#31970966)
I think it does this by not even recompiling. It just links all the uncompiled, uncompressed files and dependencies using a few functions to make them work in the browser.
Re:Vite – Next Generation Front End Tooling by toddmorey on Sunday July 03, 2022 @08:39PM (#31972317)
Credit to them for a nice "Why Vite" button backed by a very informative page.

But for any homepage describing any product / project: If you solve a similar problem as a better know competitor, that's a huge advantage! Mention them explicitly and then state what makes you different. That's one of the fastest avenues to understanding anything "it's like [well known thing] but different in that it [differences here]".

Perhaps just having this:

Vite is a javascript bundler for web development that uses native ES modules. Projects are adopting Vite in lieu of Webpack to gain near-instant HMR and much simpler setup and configuration.

Re:Vite – Next Generation Front End Tooling by cto_official on Sunday July 03, 2022 @01:14PM (#31969265)
One question .. Is the main goal to make development process easy or does it also have an impact on production performance as well ?
Re:Vite – Next Generation Front End Tooling by GiorgioG on Sunday July 03, 2022 @01:22PM (#31969316)
From https://main.vitejs.dev/guide/

"Vite (French word for "quick", pronounced /vit/, like "veet") is a build tool that aims to provide a faster and leaner development experience for modern web projects."

Ultimately it makes the dev process more productive because builds are generally much faster than most other build tools.

https://main.vitejs.dev/guide/why.html might also be worth a read

Re:Vite – Next Generation Front End Tooling by hackerbrother on Sunday July 03, 2022 @01:25PM (#31969329)
I can attest that it is a great way to spin up (and compile for server-ready HTML/CSS/JS) a React or Vue project.

Just run ‘npm init vite@latest’ and you get a basic well-organized React/Vue project ready for components and other dependencies to be dropped in.

Uses esbuild+rollup behind the scenes I believe.

If you have the luxury of picking your tools for a completely fresh web project this is a great way to do it.

Re:Vite – Next Generation Front End Tooling by pketh on Sunday July 03, 2022 @01:21PM (#31969306)
It’s mainly for dev rebuild performance. I also use vite and it’s a pretty nice build tool that’s relatively easy to configure and quite fast.

It might also affect your production build times, but prod builds are far less frequent and performance isn’t important here

Re:Vite – Next Generation Front End Tooling by bobthepanda on Sunday July 03, 2022 @01:56PM (#31969604)
Ideally, for production you're not constantly rebuilding a JS bundle but instead just building once with all the required package versions and then just serving that bundle all the time.

The bundle only really needs to change if the underlying code does, but in pretty much all cases your customers/users are not actually triggering any changes in your underlying code, that's a security risk.

Re:Vite – Next Generation Front End Tooling by mrwnmonm on Sunday July 03, 2022 @01:07PM (#31969198)
So, this is not a framework like React, right?
Re:Vite – Next Generation Front End Tooling by maigret on Sunday July 03, 2022 @01:11PM (#31969230)
It’s more like Webpack, the software that processes your React code into JavaScript bundles that are optimized for the browser. ie puts together what belongs together, removes the unused code, provides a test server to develop and get instant refresh.
Re:Vite – Next Generation Front End Tooling by eproxus on Sunday July 03, 2022 @06:35PM (#31971582)
How would one use it together with a backend that already serves the frontend code? As a compiler only?
Re:Vite – Next Generation Front End Tooling by dragonshed on Wednesday July 13, 2022 @10:50AM (#32083512)
I’ve had similar backend projects where I setup a reverse-proxy to a backend, along with the frontend dev server, to allow the full site and api to run in the browser from local host.

It’s not the most graceful setup, but it works if your backend build isn’t as flexible as you need.

Re:Vite – Next Generation Front End Tooling by DangitBobby on Monday July 04, 2022 @03:19PM (#31980744)
If you're talking about something like Django where you would want to serve frontend JS from a static assets directory, you would have to output a build bundle into your static directory. You would not get hot reloading that way, though.
Re:Vite – Next Generation Front End Tooling by maigret on Monday July 04, 2022 @03:21PM (#31980762)
You could yes, however you’ll probably have to write your configuration from scratch. You’ll have to define the JavaScript entry files (those that call the others) and put that into your HTMLs. Depending on how many scripts etc you have this might be a lot of work, but this should optimize your JavaScript to ist what you need.
Re:Vite – Next Generation Front End Tooling by arthurcolle on Sunday July 03, 2022 @07:51PM (#31972022)
I don't think Webpack is designed for that use case, it is pretty apples and oranges
Re:Vite – Next Generation Front End Tooling by mrwnmonm on Sunday July 03, 2022 @01:37PM (#31969426)
Got it, thanks
Re:Vite – Next Generation Front End Tooling by and0 on Sunday July 03, 2022 @05:49PM (#31971320)
Thanks for the info, will switch from CRA as soon as I can :D
Re:Vite – Next Generation Front End Tooling by superzamp on Sunday July 03, 2022 @12:53PM (#31969093)
Would this replace parcel or be adjacent to it?
Re:Vite – Next Generation Front End Tooling by tafath on Sunday July 03, 2022 @11:32PM (#31973229)
Re:Vite – Next Generation Front End Tooling by keb_ on Sunday July 03, 2022 @01:16PM (#31969277)
Replace it.