Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remix builds slow with projects containing a high number of routes #6630

Closed
1 task done
daniloteodoro opened this issue Jun 17, 2023 · 2 comments
Closed
1 task done

Comments

@daniloteodoro
Copy link

What version of Remix are you using?

1.17.1

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

  • Yes

Steps to Reproduce

Generate a vanilla Remix app using some basic template like indie-stack
Add 300 routes. In my case I added them on the remix.config.js file:

const remixRoutes = require('./data/remixRoutes.json');

module.exports = {

  routes: (defineRoutes) => {
    return defineRoutes((route) => {
      remixRoutes.forEach(([routePath, filePath]) => {
        route(routePath, filePath, {id: routePath});
      });
    });
  },

with remixRoutes.json having the following structure:

[
  ["/path1", "routes/helloworld.tsx"],
  ["/path2", "routes/helloworld.tsx"],
  ["/path3", "routes/helloworld.tsx"],
...
  ["/path300", "routes/helloworld.tsx"]
]

Run the app with npm run dev

Expected Behavior

Build times, especially after a change in the source-code happens in under 2 seconds

Actual Behavior

Build times are 30+ seconds. Rebuild time (hmr) is similar 😭

@daniloteodoro
Copy link
Author

@jacob-ebey

@pcattori
Copy link
Contributor

pcattori commented Jun 17, 2023

Confirmed fixed by #6629

Setup

// remix.config.js
module.exports = {
  routes: (defineRoutes) => {
    return defineRoutes((route) => {
      let i = 1;
      while (i <= 300) {
        let routePath = `/route_${i}`;
        route(routePath, "routes/helloworld.tsx", { id: routePath });
        i += 1;
      }
    });
  },
};
// app/routes/helloworld.tsx
export default function Component() {
  return <h1>heyooo</h1>;
}

Before

Screenshot 2023-06-17 at 2 57 47 PM

👆 figured out that the esbuild compilations were not the bottleneck, but rather the metafile creation. between the js and server builds. Metafile creation was taking >20s and scaling superlinearly (> O(n))

After

Screenshot 2023-06-17 at 2 57 52 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants