#slow (10 seconds+) dev server starts and hot reload not working

1 messages · Page 1 of 1 (latest)

long plaza
#

Did you try bumping to 1.16.1, it seemed to help for me

#

npx npm-upgrade makes it speedy too!

golden venture
#

how many routes does your app have?

#

and could you share your remix.config.js and your package.json scripts? want to see if/how you use unstable_dev and serverDependenciesToBundle

lime pendant
#

i'm facing the same on 1.16.1, here's the config

/** @type {import('@remix-run/dev').AppConfig} */
module.exports = {
    appDirectory: "app",
    assetsBuildDirectory: "public/build",
    cacheDirectory: ".cache",
    future: {
        unstable_dev: true,
        v2_errorBoundary: true,
        v2_meta: true,
        v2_normalizeFormMethod: true,
        v2_routeConvention: true,
    },
    ignoredRouteFiles: [
        "**/.*",
        "**/*.spec.ts",
        "**/*.spec.tsx",
        "**/*.test.ts",
        "**/*.test.tsx",
    ],
    mdx: async (_filename) => {
        const [remarkGfm] = await Promise.all([
            import("remark-gfm").then((mod) => mod.default),
        ]);

        return {
            remarkPlugins: [remarkGfm],
        };
    },
    publicPath: "/build/",
    serverPlatform: "node",
    watchPaths: ["public/locales"],
};

we have about 300 route files

golden venture
#

@lime pendant how many of your routes are mdx?

lime pendant
#

only 4

golden venture
#

@lime pendant is your repo publicly viewable?

lime pendant
#

what's the difference between remix watch and remix dev in terms of the esbuild options?

golden venture
#

if not, would you be willing to screenshare

lime pendant
#

is your repo publicly viewable?

unfortunately, no... we're backed by VC and it's a closed source SAAS for payroll processing

golden venture
lime pendant
#

but with remix watch, we're seeing only about 2s compilation time whereas remix dev takes up to 6s

golden venture
#

are you using unstable_dev?

lime pendant
#

yeah

golden venture
#

and the 6s is just the rebuild? or also the time spent waiting for you app server to be ready?

lime pendant
#

remix watch with unstable_dev=false -> 2s
remix dev with unstable_dev=true -> 6s

#

all for the remix assets initial/subsequent builds

golden venture
#

what version of Remix are you on?

lime pendant
#

1.16.1 now

golden venture
#

can you share the terminal output when initial build and subsequent rebuild occurs?

lime pendant
#

my app server, i am using the same setup like what kent was doing on the video with you

#

yeah can

golden venture
lime pendant
#

remix watch with unstable_dev=false

golden venture
#

the only difference between unstable_dev and old dev server is that unstable_dev does a separate compilation pass to detect loader changes for HDR. but that should be done in parallel to normal (re)build

lime pendant
#

remix watch with unstable_dev=true

golden venture
#

and it also never shows Built in Xms, just Rebuilt in Xms

lime pendant
#

do i have to use switch to remix dev when i do unstable_dev=true?

golden venture
lime pendant
#

correct

golden venture
#

yes remix watch is not useful with unstable_dev. you should use remix dev instead

lime pendant
#

let me share the screenshot with that

golden venture
#

can you share your package.json scripts for dev?

lime pendant
#

i wrap the commands into commands and use concurrently to run them

golden venture
#

you probably don't need to do most of that anymore with unstable_dev since you can use -c flag

lime pendant
#

i tried migrating to it, then my team told me today that they were seeing 12s on their weaker macbook, then i just moved it back to remix watch with unstable_dev=false like 4 hours ago

golden venture
#

yea we're still optimizing unstable_dev (hence the unstable part 😅), but like I said, you can try out nightly as that has one perf improvement that should make a big difference

lime pendant
#

this is what my team member shared with me, doing remix dev with unstable_dev=true, their macbook is m1 lower spec

golden venture
lime pendant
#

same, i upgraded them to 1.16.1, asked them to run a script i prepared for them which will remove node_modules/.cache/build and reinstall node_modules

golden venture
#

do you know how fast/slow the old dev server with remix watch was for them?

lime pendant
#

remix watch is about 5s to 6s for them

golden venture
#

Yea I think with nightly it should speed things up considerably for them

lime pendant
#

this is the script i had when we were on remix dev with unstable_dev=true

#

1 question i have, my current server.ts which contains expressjs, i'm using esbuild to compile myself which i'm also using watch mode (with bundle=false though), it emits the compiled JS in like 100ms, it's like the incremental build is really super fast

would it be possible for remix to do the same?

golden venture
lime pendant
#

dev:worker is a bullmq background worker which we're running to test our cron and scheduled jobs

golden venture
#

oh sorry nevermind i misread

#

thought it was the same as your -c command

lime pendant
#

oh only dev:server is the one that's related to remix assets builder

golden venture
lime pendant
#

is it because of remix does bundle everything into build/index.js?

golden venture
#

the majority of the build time is spent in CSS and browser JS, not server (unless you have .* in your serverDependenciesToBundle)

lime pendant
#

because our own express and backend code, when using esbuild with this config, it compiles the changed file in under 100ms which allows us to restart our express server in under 1s

#

the majority of the build time is spent in CSS and browser JS, not server (unless you have .* in your serverDependenciesToBundle)

ahhh the css and js bundling for browser

golden venture
#

but like I said, try out nightly and see if that speeds things up for you

lime pendant
#

let me try try

#

thanks for following up though!

golden venture
#

might see 20%-50% improvement for initial builds, and maybe some improvement for rebuilds

lime pendant
#

that's great man!!!!

golden venture
lime pendant
#

yeah trying it now

#

do i only install @remix-run/dev nightly? or the other packages also need to follow the same?

#

with nightly and remix dev + unstable_dev=true

#

with 1.16.1 and remix dev + unstable_dev=true

#

yeah it's about 18% improvement

golden venture
lime pendant
#

let me ask them to try out tomorrow

golden venture
#

@lime pendant are you relying on Remix to compile CSS for you? e.g. built-in support for tailwind or vanilla extract or postcss

lime pendant
#

this is the interesting part, we're using mantine which uses css-in-js, and we're stuck with react 17 with remix-island to workaround the assets 404 issue upon app error being thrown

#

that's why right now we also can't move to remix dev to use the HMR + HDR as remix-island requires us to wrap the outlet inside <div id="root"></div

golden venture
#

@full maple can you try commenting our your serverDependenciesToBundle, and running remix dev to see how much speed up you get from that?

#

I'm also wondering how much your build is slowed down by CSS compilation since you are using emotion, chakra, and tailwindcss

#

@full maple is your repo publicly viewable?