remix-run / remix

Build Better Websites. Create modern, resilient user experiences with web fundamentals.
https://remix.run
MIT License
29.91k stars 2.52k forks source link

dev_v2 = false is faster #6907

Closed matt-erhart closed 1 year ago

matt-erhart commented 1 year ago

What version of Remix are you using?

1.19

Are all your remix dependencies & dev-dependencies using the same version?

Steps to Reproduce

dev_v2 appears to be restarting after each edit.

I'm on windows 11, node 16.

Bonus side note: Thanks for building such a well thought out framework that's basically leading the ecosystem. React/nextjs seem to have basically endorsed the approach, and are now catching up. I think remix has a simpler, more elegant design but nextjs has a big social/marketing advantage. With nextjs/react in experimental turmoil for the 3+ months, now might be the time to really nail the social aspects of getting a framework out. A comparison table with eg dev server perf (updated with each nextjs release) and more YT would really help me sell remix to the other engineers.

Expected Behavior

brainstormbuddy commented 1 year ago

Thanks, @matt-erhart . I am a remix fun. I am very attracted remix's power. I'll review the issue and try to fix it.

pcattori commented 1 year ago

Can you share the timing reports by remix dev in your terminal? If you are seeing slow app server ready times, you can look into using manual mode (https://remix.run/docs/en/main/other-api/dev-v2#manual-mode).

matt-erhart commented 1 year ago

It was something like 300-500ms to build, and 3-4 seconds to restart the app server. V1 is working ok for me, so I probably won't go down the manual mode rabbit hole on v2. The main issue is that that v2 feels like a performance and/or setup time regression.

pcattori commented 1 year ago

v2_dev has to support more than remix-serve. Whereas remix-serve only supports Node and CJS, v2_dev supports any runtime in any JS format. That added responsibility makes the setup for non-remix-serve apps a bit more onerous, but we're looking to make it easier to opt into.

For example, the current Express template already has everything wired up for you. So you could just copy that if you wanted.

Given that the "restarting app server is slow" issue is addressed via manual mode, going to close this.

matt-erhart commented 1 year ago

Will go take a look at the express template, sounds like the Indie Stack example app is not using the optimal DX setup for v2, maybe let KCD? or who ever authored them know? I use the real-ish app examples to get a sense of new libraries, so anyone else who does the same will assume remix has slow edit times if they spin up the Indie Stack atm.

It sounds like in order to get all platforms to work without writing a compiler for each (months/quarters of work?), you needed to add a bit of copy paste and manual mode to get something working in the near term. This is honestly probably fine (but not legendary yet) if it's included in all the remix examples and doesn't really need to be changed. Manual does feel like library code I shouldn't be changing both because it's exposing chokidar direct and because things become 'my responsibility' which implies that I shouldn't be doing it, but to get the best DX I should be doing it?

kiliman commented 1 year ago

I think part of the issue with the Indie stack is that it also launches the mock service worker server, so the initial startup isn't optimized for the new v2 dev server.

If you change the dev script to "dev": "remix dev", you'll see that HMR works as expected, and it doesn't have to reboot the app server.

I also tested by ejecting from Remix App Server to Express, using my rmx-cli eject-ras script.

Changes

  "scripts": {
    "dev": "remix dev -c \"node server.mjs\"",
  }
// server.mjs
import morgan from "morgan";

+import "./mocks/index.js";

installGlobals();
image
matt-erhart commented 1 year ago

Can confirm good edit response times from npx create-remix@latest --template https://github.com/remix-run/remix/tree/main/templates/express remix_express