๐บ๏ธ Just use vite! #7632
Replies: 16 comments 27 replies
-
This is great news. Definitely makes our job easier to play with Remix (who knows, may be adopting) |
Beta Was this translation helpful? Give feedback.
-
I love this import { defineConfig } from "vite";
import { unstable_remix } from "@remix-run/vite";
export default defineConfig({
plugins: [
// remix.config.js moves to `remixConfig` here
unstable_remix(remixConfig),
],
}); A world where the framework is just a plugin of the compiler. This should also help migrate from React Router to Remix, if the RR app uses Vite it can just add the Remix plugin once the code is structured to work the same way. |
Beta Was this translation helpful? Give feedback.
-
Love it. As I understand both Remix and Vite use esbuild under the hood. It sounds like Remix changing to Vite is less about performance and more about controlling the build, integrating Vite plugins, and improved HMR. Is that right? |
Beta Was this translation helpful? Give feedback.
-
Awesome. Is this coming to 2.0.2 or perhaps available now in a nightly to try out? This might be just what I need right now. ๐ |
Beta Was this translation helpful? Give feedback.
-
For the Express |
Beta Was this translation helpful? Give feedback.
-
Awesome ๐ฅ |
Beta Was this translation helpful? Give feedback.
-
I'm just so hype |
Beta Was this translation helpful? Give feedback.
-
Have you thought about adding the possibility to just compile a Remix structured app to a SPA React Router app? This would make it even easier to gradually adopt Remix and would also allow people who cannot run a Node backend to benefit from using the Remix way of defining routes. Could this be done with a custom adapter implementation? |
Beta Was this translation helpful? Give feedback.
-
Kinda makes me nervous weโll be maintaining bundler config across all our sites like the days before meta frameworks. I dread to think the amount of time Iโve spent configuring webpack and upgrading out of date plugins etc. Having said that, Vite config looks much simpler and I guess all weโd really need is the remix plugin + static assets ๐ค |
Beta Was this translation helpful? Give feedback.
-
Assuming this moves forward, I hope you'll strongly consider taking this opportunity to match Vite by decoupling commands from modes, so that Today Remix docs and internals treat the remix/packages/remix-dev/CHANGELOG.md Lines 70 to 72 in 051d4b9 remix/packages/remix-react/components.tsx Lines 1037 to 1040 in 051d4b9 remix/packages/remix-serve/cli.ts Lines 104 to 106 in 051d4b9 As a result, By comparison, with Vite you can apparently run "Should we suppress stack traces" is a great example of something that should continue to be mode-dependent, so that you could run |
Beta Was this translation helpful? Give feedback.
-
Am I the only one confused with the @remix-run/vite package? This package is not available in the npm register or as a github repo. How do I find it then? Or is it still in development and will be published soon? |
Beta Was this translation helpful? Give feedback.
-
Being able to point to Remix for our SPA needs (and yes it's a hard "need") and our SSR needs (which we also have) is going to be a game changer. Excited to see this progress. |
Beta Was this translation helpful? Give feedback.
-
We have SPA built with Vite and served by Express. When it comes to reloading the app on code change, we utilize tsx --watch. However, any changes made in the server restart the app entirely. Can this new approach improve this issue? Additionally, we encountered difficulties with the Vite express middleware. It doesn't work greatly with tunneling like ngrok, as the Vite reloads the app before the server runs after reload. When using ngrok, there are intermittent issues with websockets that are still unclear to me. |
Beta Was this translation helpful? Give feedback.
-
With the understanding that Vite support is still experimental, would you like issues reported from testing it, and if so where? |
Beta Was this translation helpful? Give feedback.
-
Does that mean in the future remix will only be published as a plugin for vite instead of as a framework? |
Beta Was this translation helpful? Give feedback.
-
Does that mean there will be a v3 version for remix soon?
Get Outlook for iOS<https://aka.ms/o0ukef>
โฆ________________________________
From: Fireclunge ***@***.***>
Sent: Friday, November 3, 2023 10:13:20 PM
To: remix-run/remix ***@***.***>
Cc: Meng, Shaoyu ***@***.***>; Comment ***@***.***>
Subject: Re: [remix-run/remix] Just use vite! (Discussion #7632)
Correct. Going forward Remix will strictly be going forward as a Vite plug in only. Serious.
โ
Reply to this email directly, view it on GitHub<https://urldefense.com/v3/__https://github.com/remix-run/remix/discussions/7632*discussioncomment-7472250__;Iw!!DZ3fjg!4Ez8tXcZa2cmM_Ed4V8FO2mNSpdPyLaJGmjLvMpd49FTWINY7L4jkysJEYxFuRBwjx5kxPUU8dfnDdzDEeEfk-fpIcM$>, or unsubscribe<https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AJHAEC5ZGY5YDWCLRPA4ADDYCWXFBAVCNFSM6AAAAAA54DBSGKVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TINZSGI2TA__;!!DZ3fjg!4Ez8tXcZa2cmM_Ed4V8FO2mNSpdPyLaJGmjLvMpd49FTWINY7L4jkysJEYxFuRBwjx5kxPUU8dfnDdzDEeEfXEKqdjA$>.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
"Just Use Vite!"
Background
Over-reliance on compilers is often to blame for apps being slow and clunky for both the developer and users, so our initial approach with Remix was to keep it simple and limited. By keeping the compiler closed we were able to ensure builds remained fast and bundles remained small.
Unfortunately this is one of the biggest hurdles for adopting Remix. We've slowly been adding features to the Remix compiler to try to help, but it barely makes a scratch.
Preventing teams from making their own tradeoffs around compilers was never our intent and innovating in the compiler space has never really been a goal of ours.
Proposal
Because innovating in the compiler space is not a goal of Remix, we've decided to use a tool created by a community of folks who have been doing a great job at this: Vite.
Why didn't you use Vite originally?
Vite didn't exist when we started Remix, and until recently, didn't have the capabilities needed to power the development workflow of a full-stack, cross-runtime-environment framework like Remix.
For example, Vite's built-in HMR won't work as you expect if you change the data returned from a
loader
and change a component that uses that data at the same time. This is because HMR was originally designed for SPA and doesn't know anything about fetching fresh data from the app server. This is why Remix first developed HDR internally before adopting Vite.Usage
Future Flag
Because the compiler is the entry point of Remix, there is no future flag in
remix.config
for the Vite compiler.vite.config.ts and plugin
Use the
unstable_remix
plugin to configure Vite for Remix:When using Vite, the Remix config moves from
remix.config.js
to the argument passed to the Remix Vite plugin. Copy/paste it in there and delete the remix.config.js file.Some options no longer apply like
port
. Vite has its own config for these and we'll make sure to document them all.Remix CLI
Vite Plugins
The old Remix compiler supports several file types like asset imports, CSS module, MDX, etc. The Remix Vite plugin does not support those directly, but Vite does and that's the point!
TypeScript
MDX
Server Setup
Remix App Server
If you're using the Remix App Server, you just run
vite dev
, it will do the rest.Express Server
With an express server, you integrate Vite directly into your node server. That means you run your app with the same command in dev and prod:
This also avoids needing to run two processes and enables the development tooling like HMR.
Keep
@remix-run/vite
indevDependencies
and use dynamic imports to avoid installing the these dependencies in production.Your vite config will need to specify the adapter as well:
Cloudflare
I don't know yet, but Fran will.
//
Benefits
This puts app developers in charge of their compilation tradeoffs instead of Remix prescribing. Folks can use Vite's plugins to add support for whatever they need like importing
.graphql
files, svg icons, etc.Most importantly, this removes a huge adoption barrier for React Router apps to upgrade to Remix.
Beta Was this translation helpful? Give feedback.
All reactions